-
Notifications
You must be signed in to change notification settings - Fork 21
fix: do not import css or react JS unless needed #773
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
Conversation
This reverts commit d1fa674.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self review. tested locally and works fine.
no FOUC, but it's also technically a race condition ¯_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self review after adding dynamic JS loading and splitting react/ui JS out from initial page hits
Title
fix: do not import css unless needed
Description
Dynamically import CSS and app.tsx JS file only when we need to render the UI instead of on every page load.
For content-addressed data requests (the whole point of the service worker gateway), we don't need to load the CSS or react JS.
Related #759
Notes & open questions
The current CSS file is ~90kb, and an extra network request is made for every page load (2 non-cached requests when hitting a subdomain directly). Removing this should help with the initial load time.
I’ve got CSS and js for react/ui code importing dynamically now and the initial bundle size has been reduced (after redirect-config bounce changes in #759) from 255kB to 39kB for the initial javascript.. and removes 90~kb of CSS on index.html page loads.
Basically this results in a significant first-load reduction from ~32s using 3g throttling to 19s in chrome. (using “finish” time in chrome dev tools.. i.e. from the time all the network requests started (hey, gimme the content of this URL) to redirect+style+content loading + rendering being done)
without the throttling, the reduction in loadtime is improved but almost insignificant. (load time 857ms, DOMContentLoaded 476ms) — not much difference from #759
Change checklist