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

AssignedTemplateInstance performance #9

Open
luwes opened this issue Dec 31, 2022 · 1 comment
Open

AssignedTemplateInstance performance #9

luwes opened this issue Dec 31, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@luwes
Copy link
Owner

luwes commented Dec 31, 2022

Related to

// These selectors could potentially be served from the server or
// saved per unique template to make assigning the DOM parts to
// a new element faster. It will skip `parse` and `processCallback`.
//
// This would make "partial hydration" possible so the JS bundle doesn't
// need to ship with a template w/ expressions. Just the selectors would
// be needed for hydration / enhancing.
//
// The selectors include xPath like paths (ignoring whitespace nodes).
//
// format: {x: expression, p: path, o: offset, a: attributeName, n: nodesLength}
//
// {x: '0', p: '/div/h1', o: 7, a: 'class'}
// {x: '6', p: '/div/div[2]/button[2]', a: 'onclick'}
// {x: '3', p: '/div/p/text()', o: 448}
// {x: '9', p: '/div/dl/dt', n: 8}

Parsing and creating DOM parts first on a dummy template to then transfer them over to the SSR'd DOM is quite an expensive operation if wanting top performance. Fine for 90% of use cases, it's as fast as React's hydrate call.

Not needing to ship the full HTML template w/ expressions for the SSR'd content (watch out for conditional branches, these will still need the full HTML template!) is another reason to have the selector representation available straight from the server.

@luwes luwes added the enhancement New feature or request label Dec 31, 2022
@luwes luwes self-assigned this Dec 31, 2022
@luwes luwes added the help wanted Extra attention is needed label Dec 31, 2022
@JulianCataldo
Copy link

Is that remotely preventing declarative shadow DOM attachment?
Tried to do that, but template element changes its nature with "shadowroot=open", it's not a regular node anymore, and lose the "content" prop for the template extension lib to load from.

Also, not quite the topic, but I couldn't get to update the container expression with multi levels objects.
Thing like using {{user.name}} is not possible. Work-around is to pass the correct data up-front, when using update.

Great fun experimenting with your lib BTW! I think I could build a small util function to dedup. SSR / client stuff boilerplate, at least for the API user, when using the AstroJS framework. Declarative shadow DOM doesn't seems to be the right path tough, dark DOM can be hard to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants