This was a talk at JSFoo 2018. It has a number of things you can do to reduce the time it takes for your page to load, and help reduce the number of users that drop off.
of India’s most popular news sites • The digital news space is competitive, and bounce rates are high! • Many of our readers are from rural parts of the country
for Speed 90% - Last 5 Chrome, Firefox, Edge, Safari, Vivaldi The Bad Working, but slow 9% - Chrome 41+, IE11, UC Browser For My Project. Please Don’t Copy
for Speed 90% - Last 5 Chrome, Firefox, Edge, Safari, Vivaldi The Bad Working, but slow 9% - Chrome 41+, IE11, UC Browser The Ugly Don’t bother IE 6-10 For My Project. Please Don’t Copy
• Link: </user.json>; rel=preload; as=fetch • <link rel="dns-prefetch" href="//example.com"> • <link rel="preconnect" href="//example.com"> • CDNs will convert this to an HTTP2 push if it can • Fastly + Cloudflare both support this • Be careful, HTTP/2 is a mixed bag
perfect way to do critical CSS • Then, I tried to just embed the entire CSS in page • In particular, this can improve your first time page load • If using a CSP header, remember to sign your CSS
• Choose your FOUT / FOIT strategy • Font-Display is your BFF! • But can cause multiple renders. Use fontfaceobserver.js for multiple fonts • Don’t use a different CSS for your fonts
(~55%) • Serve the right image size for the right device. Use imgix, ImageKit, thumbor, CF Polish, etc…. • And use the right format too! web-p! • Use img srcset to serve the multiple devices with a single HTML tag <img src="/img.jpg" srcset="/small.jpg 200w, /medium.jpg 400w" sizes="(min-width: 1024px) 25vw, 100vw" />
'lodash'; 3: _.omit(myObject, 'lodash'); 4: 5: // Use a totally different, tiny library 6: import omit from 'object.omit'; 7: omit(myObject, 'lodash'); 8: 9: // Just import the right bit of lodash 10: import omit from 'lodash/omit'; 11: omit(myObject, 'lodash');
'lodash'; 3: _.omit(myObject, 'lodash'); 4: 5: // Use a totally different, tiny library 6: import omit from 'object.omit'; 7: omit(myObject, 'lodash'); 8: 9: // Just import the right bit of lodash 10: import omit from 'lodash/omit'; 11: omit(myObject, 'lodash'); 12: 13: // Works with Webpack 4 14: import {omit} from 'lodash'; 15: omit(myObject, 'lodash');
wasn’t nearly enough to get us to a sub second page load • We actually brought our FCP down from 3500 to 900 ms, and saw a 35% increase in traffic • This is a continuous journey. Perf day should be every day • Measure your important metrics as part of your CI