Today’s Topics 1. Why web performance matters (Isiah) 2. Analyzing speed and using devtools (Isiah) 3. Tree shaking optimizations (Kristian) 4. Network optimizations across the full stack (Noah) 5. API optimizations and caching (Omar)
Pinterest increased search engine traffic and sign-ups by 15% when they reduced perceived wait times by 40%. https://medium.com/pinterest-engineering/driving-user-growth-with-performan ce-improvements-cfc50dafadd7
What happens if you don’t optimize? Google found 53% of mobile site visits were abandoned if a page took longer than 3 seconds to load. https://www.thinkwithgoogle.com/marketing-resources/data-measurement/mo bile-page-speed-new-industry-benchmarks/
There have been rapid gains in reported internet access rates in a large number of emerging and developing nations https://www.pewresearch.org/global/2016/02/22/internet-access-growing-world wide-but-remains-higher-in-advanced-economies/
https://webpack.js.org Before tree shaking...there was bundling. Bundling is taking multiple files with dependencies and wrapping them together into a single file.
Lossy WebP images average 25–35% smaller than JPEG images of visually similar compression levels. —Mozilla source: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
What is Browser Cache? Browser cache is a temporary storage location on your local machine for resources that are downloaded by your browser to display web pages. Examples of downloaded (cached) contents: ● HTML documents ● CSS stylesheets ● JavaScript scripts ● Multimedia content
What is a Service Worker? A service worker is a script that your browser runs in the background of an web page (separate from the page), allowing features that do not require any sort of user interaction like push notifications.
Register the Service Worker if (!('serviceWorker' in navigator)) { console.log('Service Worker not supported'); return; } navigator.serviceWorker.register('/service-worker.js') .then(function(registration) { console.log('SW registered! Scope is:', registration.scope); }); // .catch a registration error https://developers.google.com/web/ilt/pwa
Installing the Service Worker self.addEventListener('install', function(event) { // Do stuff during install }); https://developers.google.com/web/ilt/pwa
Activating the Service Worker self.addEventListener('activate', function(event) { // Do stuff during activate }); https://developers.google.com/web/ilt/pwa