3 ms·
Looking at the blog post, I'd say it was for drawer.init(), contentLoader.init(), breakpoints.init(), alerts.init(), and analytics.init(). The site works fine w
by mrspeaker 8y ago
Looking at the blog post, I'd say it was for drawer.init(), contentLoader.init(), breakpoints.init(), alerts.init(), and analytics.init(). The site works fine without javascript, so it doesn't need it - perhaps the author thinks the 50k is worth the drawer, content loading, breakpoint?, and alert features and also wants a bit of user analytics tracking.
- AstralStorm 8y agoEven so, you could backload the drawer etc. placing them at the end of the document and attaching to potentially already rendered page. Reorder so that your main content loads first. Author did part of it by deferring the analytics init. Not sure why they used setTimeout though for the initialization instead of requestIdleTimeout like everything else. The page is supposed to work without JS after all. "I mentioned above that requestIdleCallback() doesn’t come with any guarantees that the callback will ever run." Not true - there's a timeout argument. It guarantees that the callback will by ran by then.