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

It works on your computer... it render fast enough?

It works on your computer... it render fast enough?

Most of us devs have a nice machine and/or a pretty fancy phone.

The sites you develop always look smooth and sweet on your devices but... Do your users have the kind of experience you wish?

In this talk I will review, on a high level, how the browser rendering works, how your HTML, CSS and/or js impacts on page rendering/loading and share techniques to minimize the impact.

presented @ codebits VI (2012) in Lisbon

Diogo Antunes

November 16, 2012
Tweet

More Decks by Diogo Antunes

Other Decks in Technology

Transcript

  1. WHO AM I? Diogo Antunes infrastructure team @ Booking.com client

    side performance improvement/optimization @dicode
  2. REPAINT changes that affect visibility of the element but not

    the layout eg. opacity, background-color
  3. REFLOW changes that affect viewport/elements size may be as expensive

    as laying out the whole page again problem is many things trigger this event
  4. REFLOW even more expensive than a repaint can be triggered

    by many actions so avoid inline css/js and even a offsetWidth/Height calculation triggers it
  5. JS RENDERING TIME the model of the web is synchronous

    when a script tag appears, it will parse and execute the script in FF and Webkit another thread continues to parse the HTML doc
  6. JS RENDERING TIME it can lock your rendering it can

    also produce repaint/reflow which means it will take longer to execute
  7. BEWARE PARALLEL CONNECTIONS IE 6-7: 2 IE 8-9: 6 Chrome,

    Firefox, Safari: 6 You can change this, but you don't want that
  8. JS scripts @ bottom async, defer, lazy load beware of

    the DOM micro optimization - really the last thing you should do
  9. specify a charset keep the number of DOM nodes as

    low as possible avoid massive depth
  10. IMAGES set width and height crop extra space around images

    use the best file format eg. use png-8, gif to reduce the number of colors in the pallette
  11. HTTP Use gzip where possible reduce dns lookups use cookieless

    domains for static content use a CDN avoid redirects
  12. FRONTEND SPOF any 3rd party widget custom font downloading even

    your own JS can cause it... wumocomicstrip.com
  13. WHAT BROWSERS SHOULD I REALLY CARE ABOUT? here comes the

    silver bullet!!! it really.... depends get to know your audience!
  14. BUILD YOUR FRONTEND CODE WISELY! some flexibility may be lost

    follow the principles but addapt them to your business customers/needs