Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce payload #2702

Merged
merged 5 commits into from
Mar 18, 2024
Merged

Reduce payload #2702

merged 5 commits into from
Mar 18, 2024

Conversation

falkoschindler
Copy link
Contributor

@falkoschindler falkoschindler commented Mar 14, 2024

This PR tries to reduce the websocket payload when updating elements.

  • exclude empty fields from the element dictionary
  • exclude the "key" prop
  • exclude the "template" field in the slot dictionaries?
  • reduce the default slot from
    "slots": {
      "default": {
        "template": null,
        "ids": [
          213,
          214
        ]
      }
    }
    
    down to
    "children": [213, 214]
    
  • remove the "id" from the dictionary values? (they are repeated as the dictionary keys)

@falkoschindler falkoschindler added the enhancement New feature or request label Mar 14, 2024
@falkoschindler falkoschindler added this to the 1.4.19 milestone Mar 14, 2024
@falkoschindler
Copy link
Contributor Author

For pushing a line to the new ui.log element (see PR #2686), this reduces the payload from

{
  "211": {
    "id": 211,
    "tag": "div",
    "class": [
      "nicegui-log",
      "w-full",
      "h-20"
    ],
    "style": {},
    "props": {
      "key": 211
    },
    "text": null,
    "slots": {
      "default": {
        "template": null,
        "ids": [
          215,
          216
        ]
      }
    },
    "events": [],
    "component": null,
    "libraries": []
  },
  "216": {
    "id": 216,
    "tag": "div",
    "class": [],
    "style": {},
    "props": {
      "key": 216
    },
    "text": "09:33:26.3",
    "slots": {
      "default": {
        "template": null,
        "ids": []
      }
    },
    "events": [],
    "component": null,
    "libraries": []
  }
}

down to

{
  "211": {
    "tag": "div",
    "class": [
      "nicegui-log",
      "w-full",
      "h-20"
    ],
    "children": [
      215,
      216
    ]
  },
  "216": {
    "tag": "div",
    "text": "13:59:20.5"
  }
}

@falkoschindler falkoschindler marked this pull request as ready for review March 18, 2024 15:49
Copy link
Member

@rodja rodja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super cool!

@falkoschindler falkoschindler merged commit 328fbab into main Mar 18, 2024
7 checks passed
@falkoschindler falkoschindler deleted the payload branch March 18, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants