SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
AIESEC IT School 2012




             Building faster websites
                      Front-end performance




Mihai Oaida<mihai.oaida@gmail.com>            1
About me

     Mihai Oaida
         Senior Web developer @imobiliare.ro
         Student M.S.E. Politehnica Timișoara
         http://www.slideshare.net/mihai.oaida




Mihai Oaida<mihai.oaida@gmail.com>                2
Agenda

     Web application architecture
     Web application performance
     Frontend performance
     The 14 rules
     Other tips
     Tools
     Conclusions


Mihai Oaida<mihai.oaida@gmail.com>   3
Web application architecture




Mihai Oaida<mihai.oaida@gmail.com>   4
Web application architecture




 http://www.webpagetest.org/

Mihai Oaida<mihai.oaida@gmail.com>   5
Web application performance

     How do you measure it ?
     How users react to it?
     Why is it important?




Mihai Oaida<mihai.oaida@gmail.com>   6
JavaScript

     Douglas Crockford on browsers:
           ”The most hostile software developement
      enviroment imaginable”
     Wrote "JavaScript the Good Parts"




Mihai Oaida<mihai.oaida@gmail.com>                   7
Frontend performance

     Time spent on the client side
     The client side model
     80-90% of the total time
     Factors
         Host machine
         Network bandwidth
         Network latency
         Number of web resources


Mihai Oaida<mihai.oaida@gmail.com>    8
The 14 rules

     Rule 1: Make fewer HTTP requests
         Use sprites for images
         Merge css files
         Merge js files
         Use multiple subdomains
                           img1.tehnologii-web.ro
                           img2.tehnologii-web.ro




Mihai Oaida<mihai.oaida@gmail.com>                   9
The 14 rules

     Rule 2: Use a CDN ( Content delivery network )
      or
         Use dedicated server(s) just for static
         Use asynchronous web servers: Lighthttpd, nginx
         Use cookie free domains
         TCP slow start
     Rule 3: Add an Expires Header
     Rule 4: Gzip Components


Mihai Oaida<mihai.oaida@gmail.com>                          10
The 14 rules

     Rule 5: Put Stylesheets at the Top
     Rule 6: Put Scripts at the Bottom
         Blocking scripts: document.write
         <script src="script.js">/script>




Mihai Oaida<mihai.oaida@gmail.com>           11
The 14 rules

     Rule 7: Avoid CSS Expressions
     Rule 8: Make JavaScript and CSS External
     Rule 9: Reduce DNS Lookups
     Rule 10: Minify JavaScript




Mihai Oaida<mihai.oaida@gmail.com>               12
The 14 rules

     Rule 11: Avoid Redirects
     Rule 12: Remove Duplicate Scripts
     Rule 13: Configure Etags
     Rule 14: Make Ajax Cacheable




Mihai Oaida<mihai.oaida@gmail.com>        13
Lazy loading

     scripts,Images,ads
     70-80% downloaded code is not executed
        immediately for payloads of 100-300K
     No blocking javascript
     Example: google image search




Mihai Oaida<mihai.oaida@gmail.com>             14
Lazy execution

     Execute js code faster than with eval()

 function sayHi(){
      scriptContent = 'alert("hi")';
      scriptElem = document.createElement('script');
      head = document.getElementByTagName('head')[0]
      head.appendChild(scriptElem);
      scriptElem.text = scriptContent
 }


Mihai Oaida<mihai.oaida@gmail.com>                     15
Lazy loading

     Dynamic load script after page load
 function loadScript(){
       scriptElem = document.createElement('script');
       scriptElem.src = "http://domain.com/script.js";
       head = document.getElementByTagName('head')[0]
       head.appendChild(scriptElem);
 }




Mihai Oaida<mihai.oaida@gmail.com>                       16
Profiling

     document end
         download rate
         parsing time
         inline javascript execution
     document load
         on load event - all resources loaded




Mihai Oaida<mihai.oaida@gmail.com>               17
Profiling - After <head>

 <script type="text/javascript">
     documentStart = new Date().getTime();
 </script>




Mihai Oaida<mihai.oaida@gmail.com>           18
Profiling - Before </body>

 <script type="text/javascript">
 documentEnd = new Date().getTime()-documentStart;

 jQuery(window).load(function(){

       callbackUrl ='http://www.foo.ro/timing';
       documentLoad = new Date().getTime()-documentStart;
         profileTokens = {
            'document_end':documentEnd,
            'document_load':documentLoad,
            'page' : window.location.href.split('.ro')[1]
         };




Mihai Oaida<mihai.oaida@gmail.com>                          19
Profiling - Before </body>

           i=0;
           for(k in profileTokens) {
              delim = (i==0?'?':'&');
              callbackUrl+= delim+k+'='+profileTokens[k];
              i++;
           };

         img = document.createElement('img');
         img.src = callbackUrl;
         document.body.appendChild(img);
       });

 </script>




Mihai Oaida<mihai.oaida@gmail.com>                          20
Tools

     Tools
         HttpWatch
         Wireshark
         Firebug
         Yslow
         Web developement Tools
         http://www.webpagetest.org/
         http://smush.it/
     Resources:
         http://stevesouders.com/hpws/

Mihai Oaida<mihai.oaida@gmail.com>        21
Conclusions

     Each rule has a different impact
     Rules are not all mandatory
     Measure first
     Measure after




Mihai Oaida<mihai.oaida@gmail.com>       22
Thank you!




Mihai Oaida<mihai.oaida@gmail.com>                23

Contenu connexe

Tendances

Building a Drupal-driven Intranet
Building a Drupal-driven IntranetBuilding a Drupal-driven Intranet
Building a Drupal-driven Intranet
librarywebchic
 
Cloud computing
Cloud computingCloud computing
Cloud computing
hwalice666
 
雲端運算 英文Ppt
雲端運算 英文Ppt雲端運算 英文Ppt
雲端運算 英文Ppt
hwalice666
 
Session 2 branding and site development in SharePoint
Session 2   branding and site development in SharePointSession 2   branding and site development in SharePoint
Session 2 branding and site development in SharePoint
Khoa Quach
 

Tendances (20)

Building Better WordPress Sites
Building Better WordPress SitesBuilding Better WordPress Sites
Building Better WordPress Sites
 
Blazor certification training - Dot Net Tricks
Blazor certification training - Dot Net TricksBlazor certification training - Dot Net Tricks
Blazor certification training - Dot Net Tricks
 
Ajax Presentation
Ajax PresentationAjax Presentation
Ajax Presentation
 
Cloud Expo Europe 2014: Practical methods to improve your security in the cloud
Cloud Expo Europe 2014: Practical methods to improve your security in the cloudCloud Expo Europe 2014: Practical methods to improve your security in the cloud
Cloud Expo Europe 2014: Practical methods to improve your security in the cloud
 
Securing data and preventing data breaches
Securing data and preventing data breachesSecuring data and preventing data breaches
Securing data and preventing data breaches
 
Semi Structured Data
Semi Structured DataSemi Structured Data
Semi Structured Data
 
Squeezing Web Performance
Squeezing Web PerformanceSqueezing Web Performance
Squeezing Web Performance
 
Building a Drupal-driven Intranet
Building a Drupal-driven IntranetBuilding a Drupal-driven Intranet
Building a Drupal-driven Intranet
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
雲端運算 英文Ppt
雲端運算 英文Ppt雲端運算 英文Ppt
雲端運算 英文Ppt
 
Session 2 branding and site development in SharePoint
Session 2   branding and site development in SharePointSession 2   branding and site development in SharePoint
Session 2 branding and site development in SharePoint
 
Bioschemas - TeSS Integration @ Rothamsted Hackathon 2016
Bioschemas - TeSS Integration @ Rothamsted Hackathon 2016Bioschemas - TeSS Integration @ Rothamsted Hackathon 2016
Bioschemas - TeSS Integration @ Rothamsted Hackathon 2016
 
Fast, Powerful and Scalable Analytics
Fast, Powerful and Scalable AnalyticsFast, Powerful and Scalable Analytics
Fast, Powerful and Scalable Analytics
 
Working with Data in Service Workers
Working with Data in Service WorkersWorking with Data in Service Workers
Working with Data in Service Workers
 
Ajax
AjaxAjax
Ajax
 
AWS Summit Berlin 2013 - doo - A Scalable Sync Framework Infrastructure based...
AWS Summit Berlin 2013 - doo - A Scalable Sync Framework Infrastructure based...AWS Summit Berlin 2013 - doo - A Scalable Sync Framework Infrastructure based...
AWS Summit Berlin 2013 - doo - A Scalable Sync Framework Infrastructure based...
 
Dynamic to-static
Dynamic to-staticDynamic to-static
Dynamic to-static
 
CSF18 - External Collaboration with Azure B2B - Sjoukje Zaal
CSF18 - External Collaboration with Azure B2B - Sjoukje ZaalCSF18 - External Collaboration with Azure B2B - Sjoukje Zaal
CSF18 - External Collaboration with Azure B2B - Sjoukje Zaal
 
Building a Database for the Future with MongoDB Atlas
Building a Database for the Future with MongoDB AtlasBuilding a Database for the Future with MongoDB Atlas
Building a Database for the Future with MongoDB Atlas
 

En vedette

En vedette (7)

K-Means
K-MeansK-Means
K-Means
 
Notiuni avansate MySQL - Infoeducatie 2008
Notiuni avansate MySQL - Infoeducatie 2008Notiuni avansate MySQL - Infoeducatie 2008
Notiuni avansate MySQL - Infoeducatie 2008
 
jQuery - GeekMeet Timisoara
jQuery - GeekMeet TimisoarajQuery - GeekMeet Timisoara
jQuery - GeekMeet Timisoara
 
Arhitecturi de cacheing server side - LVLE 2009
Arhitecturi de cacheing server side - LVLE 2009Arhitecturi de cacheing server side - LVLE 2009
Arhitecturi de cacheing server side - LVLE 2009
 
Notiuni avansate MySQL - LVLE 2009
Notiuni avansate MySQL - LVLE 2009Notiuni avansate MySQL - LVLE 2009
Notiuni avansate MySQL - LVLE 2009
 
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
 
Linux/Unix-based Operating Systems
Linux/Unix-based Operating SystemsLinux/Unix-based Operating Systems
Linux/Unix-based Operating Systems
 

Similaire à Building faster websites Front-end performance

Polymer
Polymer Polymer
Polymer
jskvara
 
Moving from ASP.NET Web Forms to ASP.NET MVC
Moving from ASP.NET Web Forms to ASP.NET MVCMoving from ASP.NET Web Forms to ASP.NET MVC
Moving from ASP.NET Web Forms to ASP.NET MVC
kgpainter
 
Ahmed Mohamed Awad Senior Web Developer
Ahmed Mohamed Awad Senior Web DeveloperAhmed Mohamed Awad Senior Web Developer
Ahmed Mohamed Awad Senior Web Developer
Ahmed Awad
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
DataLeader.io
 

Similaire à Building faster websites Front-end performance (20)

Polymer
Polymer Polymer
Polymer
 
A brave new web - A talk about Web Components
A brave new web - A talk about Web ComponentsA brave new web - A talk about Web Components
A brave new web - A talk about Web Components
 
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch Tutorial
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
 
Edge 2016 service workers and other front end techniques
Edge 2016 service workers and other front end techniquesEdge 2016 service workers and other front end techniques
Edge 2016 service workers and other front end techniques
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applications
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Server rendering-talk
Server rendering-talkServer rendering-talk
Server rendering-talk
 
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB.local Dallas 2019: MongoDB Stitch TutorialMongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
 
Moving from ASP.NET Web Forms to ASP.NET MVC
Moving from ASP.NET Web Forms to ASP.NET MVCMoving from ASP.NET Web Forms to ASP.NET MVC
Moving from ASP.NET Web Forms to ASP.NET MVC
 
Ahmed Mohamed Awad Senior Web Developer
Ahmed Mohamed Awad Senior Web DeveloperAhmed Mohamed Awad Senior Web Developer
Ahmed Mohamed Awad Senior Web Developer
 
XCS110_All_Slides.pdf
XCS110_All_Slides.pdfXCS110_All_Slides.pdf
XCS110_All_Slides.pdf
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
 
Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pages
 
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
 
Frameworks
FrameworksFrameworks
Frameworks
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
Bp101-Can Domino Be Hacked
Bp101-Can Domino Be HackedBp101-Can Domino Be Hacked
Bp101-Can Domino Be Hacked
 
Monitoring web application response times, a new approach
Monitoring web application response times, a new approachMonitoring web application response times, a new approach
Monitoring web application response times, a new approach
 

Plus de Mihai Oaida

Plus de Mihai Oaida (6)

Advanced Mysql - GeekMeet Timisoara
Advanced Mysql - GeekMeet TimisoaraAdvanced Mysql - GeekMeet Timisoara
Advanced Mysql - GeekMeet Timisoara
 
Notiuni avansate MySQL - Infoeducatie 2009
Notiuni avansate MySQL - Infoeducatie 2009Notiuni avansate MySQL - Infoeducatie 2009
Notiuni avansate MySQL - Infoeducatie 2009
 
jQuery - Infoeducatie 2008
jQuery - Infoeducatie 2008jQuery - Infoeducatie 2008
jQuery - Infoeducatie 2008
 
Arhitecturi de caching server-side - Infoeducatie 2008
Arhitecturi de caching server-side - Infoeducatie 2008 Arhitecturi de caching server-side - Infoeducatie 2008
Arhitecturi de caching server-side - Infoeducatie 2008
 
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
 
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Building faster websites Front-end performance

  • 1. AIESEC IT School 2012 Building faster websites Front-end performance Mihai Oaida<mihai.oaida@gmail.com> 1
  • 2. About me  Mihai Oaida  Senior Web developer @imobiliare.ro  Student M.S.E. Politehnica Timișoara  http://www.slideshare.net/mihai.oaida Mihai Oaida<mihai.oaida@gmail.com> 2
  • 3. Agenda  Web application architecture  Web application performance  Frontend performance  The 14 rules  Other tips  Tools  Conclusions Mihai Oaida<mihai.oaida@gmail.com> 3
  • 4. Web application architecture Mihai Oaida<mihai.oaida@gmail.com> 4
  • 5. Web application architecture http://www.webpagetest.org/ Mihai Oaida<mihai.oaida@gmail.com> 5
  • 6. Web application performance  How do you measure it ?  How users react to it?  Why is it important? Mihai Oaida<mihai.oaida@gmail.com> 6
  • 7. JavaScript  Douglas Crockford on browsers: ”The most hostile software developement enviroment imaginable”  Wrote "JavaScript the Good Parts" Mihai Oaida<mihai.oaida@gmail.com> 7
  • 8. Frontend performance  Time spent on the client side  The client side model  80-90% of the total time  Factors  Host machine  Network bandwidth  Network latency  Number of web resources Mihai Oaida<mihai.oaida@gmail.com> 8
  • 9. The 14 rules  Rule 1: Make fewer HTTP requests  Use sprites for images  Merge css files  Merge js files  Use multiple subdomains  img1.tehnologii-web.ro  img2.tehnologii-web.ro Mihai Oaida<mihai.oaida@gmail.com> 9
  • 10. The 14 rules  Rule 2: Use a CDN ( Content delivery network ) or  Use dedicated server(s) just for static  Use asynchronous web servers: Lighthttpd, nginx  Use cookie free domains  TCP slow start  Rule 3: Add an Expires Header  Rule 4: Gzip Components Mihai Oaida<mihai.oaida@gmail.com> 10
  • 11. The 14 rules  Rule 5: Put Stylesheets at the Top  Rule 6: Put Scripts at the Bottom  Blocking scripts: document.write  <script src="script.js">/script> Mihai Oaida<mihai.oaida@gmail.com> 11
  • 12. The 14 rules  Rule 7: Avoid CSS Expressions  Rule 8: Make JavaScript and CSS External  Rule 9: Reduce DNS Lookups  Rule 10: Minify JavaScript Mihai Oaida<mihai.oaida@gmail.com> 12
  • 13. The 14 rules  Rule 11: Avoid Redirects  Rule 12: Remove Duplicate Scripts  Rule 13: Configure Etags  Rule 14: Make Ajax Cacheable Mihai Oaida<mihai.oaida@gmail.com> 13
  • 14. Lazy loading  scripts,Images,ads  70-80% downloaded code is not executed immediately for payloads of 100-300K  No blocking javascript  Example: google image search Mihai Oaida<mihai.oaida@gmail.com> 14
  • 15. Lazy execution  Execute js code faster than with eval() function sayHi(){ scriptContent = 'alert("hi")'; scriptElem = document.createElement('script'); head = document.getElementByTagName('head')[0] head.appendChild(scriptElem); scriptElem.text = scriptContent } Mihai Oaida<mihai.oaida@gmail.com> 15
  • 16. Lazy loading  Dynamic load script after page load function loadScript(){ scriptElem = document.createElement('script'); scriptElem.src = "http://domain.com/script.js"; head = document.getElementByTagName('head')[0] head.appendChild(scriptElem); } Mihai Oaida<mihai.oaida@gmail.com> 16
  • 17. Profiling  document end  download rate  parsing time  inline javascript execution  document load  on load event - all resources loaded Mihai Oaida<mihai.oaida@gmail.com> 17
  • 18. Profiling - After <head> <script type="text/javascript"> documentStart = new Date().getTime(); </script> Mihai Oaida<mihai.oaida@gmail.com> 18
  • 19. Profiling - Before </body> <script type="text/javascript"> documentEnd = new Date().getTime()-documentStart; jQuery(window).load(function(){ callbackUrl ='http://www.foo.ro/timing'; documentLoad = new Date().getTime()-documentStart; profileTokens = { 'document_end':documentEnd, 'document_load':documentLoad, 'page' : window.location.href.split('.ro')[1] }; Mihai Oaida<mihai.oaida@gmail.com> 19
  • 20. Profiling - Before </body> i=0; for(k in profileTokens) { delim = (i==0?'?':'&'); callbackUrl+= delim+k+'='+profileTokens[k]; i++; }; img = document.createElement('img'); img.src = callbackUrl; document.body.appendChild(img); }); </script> Mihai Oaida<mihai.oaida@gmail.com> 20
  • 21. Tools  Tools  HttpWatch  Wireshark  Firebug  Yslow  Web developement Tools  http://www.webpagetest.org/  http://smush.it/  Resources:  http://stevesouders.com/hpws/ Mihai Oaida<mihai.oaida@gmail.com> 21
  • 22. Conclusions  Each rule has a different impact  Rules are not all mandatory  Measure first  Measure after Mihai Oaida<mihai.oaida@gmail.com> 22