pages • More JS the more to parse • Costly to the users data • One error can potential break the whole bundle • Polyfill’s can find their way in easily • Vendor files get downloaded on pages that may not need them
Service Worker caching static assets & offline page • ?cb=querystring cachebusters • One fat bundle L • Stupid amounts of third party JavaScript Our challenge: Load only the JavaScript that the page needs rather than sending it all.
components use it and a carousel plugin • Slick-Carousel 45kb – components use this • Masonry-Layout 23kb – one component uses this • Lazysizes 7kb – needed on all pages • Imagesloaded 5.5kb – one component uses this
with a vanilla alternative – potential loss of 34kb off each page. • Server side rendering of the split components so we can preload them & remove the dependency for one file to load all scripts.
polyfills in. Use polyfill.io to do the hard work for you. • Put all files in one vendor bundle or let webpack figure out when to download a certain vendor with dynamic imports • Use dynamic imports to: • Check if components exist in the page before loading • Lazyload components on scroll (optional) • Lazyloading when interacted with (optional)