Please Don’t Touch
       the Slow Parts

                        francesco.fullone@ideato.it
                            http://www.ideato.it/

                        federico.galassi@gmail.com
                         http://federico.galassi.net/

Saturday, May 8, 2010
Saturday, May 8, 2010
fast er

Saturday, May 8, 2010
fast er WEB

Saturday, May 8, 2010
Faster == Better?



Saturday, May 8, 2010
We have to wait



Saturday, May 8, 2010
... All the time



Saturday, May 8, 2010
“Savings in time
                        feels like simplicity”



Saturday, May 8, 2010
“Time is the only
 commodity that matters”



Saturday, May 8, 2010
Faster web, more clicks




                 http://www.stevesouders.com/blog/2009/07/27/wikia-fast-pages-retain-users/
Saturday, May 8, 2010
Faster web, better SEO




http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html
Saturday, May 8, 2010
Faster web is hot




Saturday, May 8, 2010
Say web, Say browser




Saturday, May 8, 2010
How browsers work




Saturday, May 8, 2010
User clicks on a link




Saturday, May 8, 2010
Browser resolves
                          domain name                           DNS

                                          UDP

                               www.google.com




                                                72.14.234.104




           domain

Saturday, May 8, 2010
Browser connects to
                 web server
                                                  WEB
                                     TCP/IP

                                  72.14.234.104




           domain       connect

Saturday, May 8, 2010
Browser sends a
                        request for a page
                                                                      WEB
                                                   HTTP
                                          GET /language_tools?hl=en
                                          Host: www.google.com




           domain        connect   send

Saturday, May 8, 2010
Browser receives a
     response with the page
                                                          WEB




                                                   HTTP

                                               200 OK




           domain       connect   send   receive

Saturday, May 8, 2010
Browser renders the
                 new page



           domain       connect   send   receive   render

Saturday, May 8, 2010
Rendering is complex
              parse + paint
                        render




Saturday, May 8, 2010
Rendering really complex
parse + paint + resources
                                                   render

                        css

                              css

                                    img

                                          img

                                           javascript

                                                  javascript

                                                        flash
Saturday, May 8, 2010
Each resource is another
         web request
                        render




Saturday, May 8, 2010
Requests are
                 processed in parallel
                          render




Saturday, May 8, 2010
Once upon a time...
                             Static pages
                             Few resources
                             Less javascript
Saturday, May 8, 2010
Most time on server
         domain connect   send   receive   render




Saturday, May 8, 2010
Solution is faster serverside
         domain connect   send   receive   render




Saturday, May 8, 2010
Ajax revolution




Saturday, May 8, 2010
Most time on browser
         domain connect   send   receive   render




Saturday, May 8, 2010
Golden rule of faster web
         80% of the end user
        response time is spent
           on the front-end

Saturday, May 8, 2010
Golden rule of faster web
                        Start there.



Saturday, May 8, 2010
Why web
                        slow parts?



Saturday, May 8, 2010
Easy to understand




Saturday, May 8, 2010
Each part has its rules




Saturday, May 8, 2010
Which parts are slow?




Saturday, May 8, 2010
Network is slow




Saturday, May 8, 2010
Less stuff
                        Fewer requests
                                  Pages have too
                                  many resources


                                  Concatenate js/css
                                  Css sprites
                                  Less dns requests
Saturday, May 8, 2010
Less stuff
                        Cache requests
                                  Browser download
                                  resources repeatedly

                                  Expires header
                                  Revving Files
                                  External js/css
                                  Remove etags
Saturday, May 8, 2010
Smaller stuff
              Compress responses
                          Resources are
                          too big


                          Content-Encoding
                          Gzip
                          Deflate
Saturday, May 8, 2010
Smaller stuff
                        Minify responses
                                   Resources are
                                   too big


                                   js, css, html
                                   remove formatting
                                   remove comments
                                   use tools
Saturday, May 8, 2010
Closer stuff
                        Use a CDN
                                   Resources are
                                   too far


                                   reduce latency



Saturday, May 8, 2010
Browser is slow




Saturday, May 8, 2010
Scripts block loading
                 html
                                                         document.write
                        javascript
                                                         location.href
                                        css
                                                         scripts order
                                        img

                                     javascript

                                                  img

                                                  flash

Saturday, May 8, 2010
Put scripts at bottom
                  html

                         css

                         img

                               img

                               flash

                                      javascript

                                                   javascript
Saturday, May 8, 2010
Unloaded styles
           block page rendering
                        html

                               img

                               img

                               flash

                               css




Saturday, May 8, 2010
Put styles at top
                        html

                               css

                               img

                               img

                               flash




Saturday, May 8, 2010
Scripts and styles
                           side effects

        dom reflows
        css expression reflows



Saturday, May 8, 2010
All that glitters
                          is not gold



Saturday, May 8, 2010
Everything is a
                           tradeoff



Saturday, May 8, 2010
performance brings
                    complexity



Saturday, May 8, 2010
know the rules but...




Saturday, May 8, 2010
leave complexity
                          to computers



Saturday, May 8, 2010
use libraries
              during development



Saturday, May 8, 2010
Use tools
                        at build time



Saturday, May 8, 2010
http://abetterbrowser.org/
Saturday, May 8, 2010
Questions?




Saturday, May 8, 2010

Please Don't Touch the Slow Parts