You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't understand Preact internals. Is it even possible? This might be a very tricky problem to solve but I believe it worth it. Our own apps are exploding it bundle size and most of the bundle is just static strings.
The text was updated successfully, but these errors were encountered:
Could maybe do this in userland by having a scanner that converts DOM to VDOM and then provides a component that can insert that VDOM in place. Hard to ditch the static via Babel though, JSX isn't very deterministic.
Determining which string can be safely removed will be extremely tricky due to the highly dynamic nature of JavaScript. Whilst this is an interesting idea it's out of scope for us to tackle. For this to work one would need to plugin into one of the existing compilers and extend them.
When using Preact with server-side rendering we're transferring a parts of the app to the client two times!
Consider following app:
Server will render the app with the string
"Lorem ipsum"
in the HTML. The client bundle has the string"Lorem ipsum"
in it as well.Solution
Make a transformer(Babel or TypeScript) that removes static content from client bundle
By removing static content that's possible to recover from rendered HTML we can reduce the bundle size:
Make client render use existing HTML to hydrate its virtual DOM.
We might have to put markers to maintain order of children in components. For instance:
Should be transformed into something like this:
Recovering more than just strings from HTML.
If we can determine part of component is completely static we can remove it entirely and recover it from HTML:
Tranfroms into:
I don't understand Preact internals. Is it even possible? This might be a very tricky problem to solve but I believe it worth it. Our own apps are exploding it bundle size and most of the bundle is just static strings.
The text was updated successfully, but these errors were encountered: