-
Notifications
You must be signed in to change notification settings - Fork 503
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
Lazy load BCD table #96
Comments
I made a rough branch that started implementing this. First, the
You can see the result here: https://stumptown-peterbe-lazy-load-bcd-tables.s3-us-west-1.amazonaws.com/en-US/docs/Web/HTML/Element/video/index.html That
So, before the browser had to download 19K, now it has to download 15K + 1K = 16K. If this wasn't a direct hit but that the user client-side navigated to the page, the
So, before the browser had to download 9K, now it has to download 8K + 1K = 9K. Basically, there's a small win here in terms of amount of data that needs to be shipped from the CDN to the client. But the browser's JS now has to do more, which is to start an XHR request and once that comes back execute the React component and update the DOM. That's potentially additional load on the main thread but in principle it's work that can start after the page has been fully rendered and considered complete. Smaller data up-front means the browser can get started displaying useful above-the-fold content sooner. But more CPU work is needed by the browser, although it's reasonably nicely staggered. |
The next step is to not just lazy-load the data but also fully lazy load the JavaScript and maybe also the CSS. That follows the same principle as above but just more extreme. The initial doc's CSS and JS will be smaller but that JS and CSS still needs to be transmitted from the server to the browser. |
Perhaps the next step now is to wrap the browser This feels somewhat orthogonal to the idea of code splitting but perhaps safest to do one thing at a time. |
I just wanted to drop a note so I don't lose the research. If you remove that data, from the serialized JSON, how does that affect the HTML? Here's the answer:
Basically, we can make the document 11KB smaller by not having the BCD table server-side rendered in the document. |
#187 is now rotten. Also that PR solved it by creating one |
Important note-to-self; a great test page is this one: http://localhost:5000/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs/ |
The BCD table is always far down. So it shouldn't block the rendering path.
Also, we should totally consider to use an intersection observer so that we only bother to load it if the user scrolls it into view.
Goal: Smaller HTML, smaller
index.json
, less CSS, less JS CPU work; still perfectly fine looking BCD table for those who scroll down.__compat
stuff in theindex.json
files should be omitted.preload
things in case the user eventually scrolls the BCD table into view.The text was updated successfully, but these errors were encountered: