Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance: Small Tweaks, Big Gains

Performance: Small Tweaks, Big Gains

Recently I have been focusing a lot around performance on Hillarys and Id like to share some of the quick wins with you all.

Matthew Claffey

May 23, 2017
Tweet

More Decks by Matthew Claffey

Other Decks in Programming

Transcript

  1. § Frontend Developer @ Code § Based in Manchester §

    Twitter - @mattclaffey1 § Github – code-mattclaffey About Me
  2. L

  3. L - Time constraints - It doesn't block sites from

    going live - Client/PM doesn’t priorities it over features - “Gets lost in the backlog”
  4. 40% of users will leave a page that takes longer

    than three seconds to load. https://blog.kissmetrics.com/loading-time/
  5. 79% of shoppers who are dissatisfied with site performance say

    they're less likely to purchase from the same site again. https://blog.kissmetrics.com/loading-time/
  6. Amazon reduced their page load by 100 ms. They lost

    1%. Amazon makes $15.7 billion. 1% = $157 million. :o
  7. Benefits § Content appears on the page quicker § Improves

    perceived performance § Easy to implement § Can be implemented on TypeKit Fonts § Progressively enhancing our site
  8. On Desktop I would like to see images in the

    navigation but have them hidden on mobile…
  9. Benefits § Can dramatically reduce page weight on mobile §

    Reduces a lot of requests § Reduces total page load
  10. Pros & Cons § Reduces page weight § Improves perceived

    performance (if using placeholders) § Implementing the placeholder can be tricky on images that do not contain their aspect ratios.
  11. Pros & Cons § Reduces page weight on first load

    § Reduces images requests on first load § Removes images that are render blocking § 3G connections will take a lot longer to load in assets.
  12. Pros & Cons § Improves start render times § Removes

    jQuery from render blocking the page § Might not work if something depends on jQuery. (Third party scripts)
  13. Pros & Cons § Improves perceived performance § Allows you

    to load assets in priority over others § Very quick to implement § Preloading everything has no value § Preloading large assets can slow your start render down § Browser Support is’nt great yet.
  14. Iya Grigorik – “Preconnect is an important tool in your

    optimization toolbox… it can eliminate many costly roundtrips from your request path – in some cases reducing the request latency by hundreds and even thousands of milliseconds” https://www.keycdn.com/blog/resource-hints/
  15. Pros & Cons § Removes any costly roundtrips from your

    request path § Reduces page load § Very quick to implement § Browser Support isn't great yet.
  16. Assets YouTube Needs: § OUB6zKc-Tos - 22.5kb (11.5kb Gzip) §

    www-embed-player-sprite-mode-2x.css 256kb (43.4kb Gzip) § www-embed-player 92.4kb (34.3kb Gzip) § base.js 1.2mb (405kb Gzip) § Roboto font 13kb § sddefault.jpg 36.8kb § player-cougar-2x-id.png 98.6kb 635kb!!!!!! :o
  17. Pros & Cons § Using existing code § Easy to

    implement § It will still load the element if it sits in the fold § Can take a while to load when scrolled down on 3G
  18. Pros & Cons § - 635kb in page weight §

    The component image can be lazy loaded § Easy to implement § ?autoplay doesn't work on mobile. § YouTube could take a few seconds on 3G to load when play is clicked.
  19. Request Page Build DOM Build CSS idle idle Gets HTML

    Render Blocking - GET CSS -> Render Page
  20. Request Page Build DOM Build Critical CSS idle Gets HTML

    Render Page Load Async CSS Load Async CSS
  21. What should we embed? § Font styles § Layout styles

    § Components that sit in the fold
  22. Header Banner Article Header Form section Header Product Product Product

    Product Critical-home.css Critical-application.css Critical-product.css
  23. Pros & Cons § Removes any render blocking for css

    § Improving start render times § Preload is not massively support yet § Difficult to implement on a CMS site
  24. Reflection § Getting the content to the user quicker with

    FOUC § Use image-hidden when images have display none; § Use responsive images to reduce page weight § Load images that are only in the fold with Lazy loading § Reduce our time to first byte by removing render blocking scripts § Preloading important assets in the fold § Reducing costly roundtrips with preconnect & dns-prefetch § Not to embed YouTube videos straight away § Use woff & woff2 § Loading in the fold styles and loading the rest async