Web 2.0 Expo: Even Faster Web Sites

Steve Souders [email_address] http://stevesouders.com/ Even Faster Web Sites   best practices for faster pages  Disclaimer:  This content does not necessarily reflect the opinions of my employer.
The Importance of Frontend Performance 17% 83% iGoogle, primed cache 9% 91% iGoogle, empty cache
Time Spent on the Frontend Empty Cache Primed Cache www.aol.com 97% 97% www.ebay.com 95% 81% www.facebook.com 95% 81% www.google.com/search 47% 0% search.live.com/results 67% 0% www.msn.com 98% 94% www.myspace.com 98% 98% en.wikipedia.org/wiki 94% 91% www.yahoo.com 97% 96% www.youtube.com 98% 97%
The Performance Golden Rule 80-90% of the end-user response time is  spent on the frontend. Start there. greater potential for improvement simpler proven to work
14 Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
High Performance Web Sites YSlow
[object Object]
Even Faster Web Sites ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why focus on JavaScript? AOL eBay Facebook MySpace Wikipedia Yahoo! YouTube
Scripts Block <script src=&quot;A.js&quot;>  blocks parallel downloads and rendering What's &quot;Cuzillion&quot;? http://stevesouders.com/cuzillion/?ex=10008
Cuzillion 'cuz there are a zillion pages to check a tool for quickly constructing web pages to see how components interact Open Source http://stevesouders.com/cuzillion/
Split the Initial Payload: Facebook 43 external scripts, 550K uncompressed 9% of functionality is used before onload
Unexecuted Payload 73.6% avg functions  not used  before onload www.aol.com 70% www.ebay.com 56% www.facebook.com 91% www.google.com/search 55% search.live.com/results 76% www.msn.com 69% www.myspace.com 82% en.wikipedia.org/wiki 68% www.yahoo.com 87% www.youtube.com 82%
Split the initial payload split your JavaScript between what's needed to render the page and everything else load &quot;everything else&quot;  after  the page is rendered separate manually (Firebug); tools needed to automate this (Doloto from Microsoft) load scripts without blocking – how?
MSN.com: Parallel Scripts Scripts and other resources downloaded in parallel! How? var p=g.getElementsByTagName(&quot;HEAD&quot;)[0]; var c=g.createElement(&quot;script&quot;); c.type=&quot;text/javascript&quot;; c.onreadystatechange=n; c.onerror=c.onload=k; c.src=e; p.appendChild(c) MSN
Advanced Script Loading XHR Eval XHR Injection Script in Iframe Script DOM Element Script Defer document.write Script Tag
XHR Eval script must have same domain as main page must refactor script var xhrObj = getXHRObject(); xhrObj.onreadystatechange =  function() {  if ( xhrObj.readyState != 4 ) return; eval(xhrObj.responseText); }; xhrObj.open('GET', 'A.js', true); xhrObj.send(''); http://stevesouders.com/cuzillion/?ex=10009
XHR Injection var xhrObj = getXHRObject(); xhrObj.onreadystatechange =  function() {  if ( xhrObj.readyState != 4 ) return; var se=document.createElement('script'); document.getElementsByTagName('head') [0].appendChild(se); se.text = xhrObj.responseText; }; xhrObj.open('GET', 'A.js', true); xhrObj.send(''); script must have same domain as main page http://stevesouders.com/cuzillion/?ex=10015
Script in Iframe <iframe  src='A.html'  width=0 height=0  frameborder=0 id=frame1></iframe>  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://stevesouders.com/cuzillion/?ex=10012
Script DOM Element var se = document.createElement('script'); se.src = 'http://anydomain.com/A.js'; document.getElementsByTagName('head') [0].appendChild(se);  script and main page domains can differ no need to refactor JavaScript http://stevesouders.com/cuzillion/?ex=10010
Script Defer <script  defer  src='A.js'></script> only supported in IE script and main page domains can differ no need to refactor JavaScript http://stevesouders.com/cuzillion/?ex=10013
document.write  Script Tag document.write (&quot;<scri&quot; +  &quot;ipt type='text/javascript' src='A.js'>&quot; + &quot;</scri&quot; + &quot;ipt>&quot;); parallelization only works in IE parallel downloads for scripts, nothing else all  document.write s must be in same script block http://stevesouders.com/cuzillion/?ex=10014
Browser Busy Indicators
Browser Busy Indicators good  to show busy indicators when the user needs feedback bad  when downloading in the background
Ensure/Avoid Ordered Execution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary of Traits * Only other document.write scripts are downloaded in parallel (in the same script block).
and the winner is...
Load Scripts without Blocking ,[object Object],[object Object],[object Object]
Inline Scripts Block Rendering ,[object Object],[object Object],[object Object],[object Object],[object Object]
Inline Scripts after Stylesheets  Block Downloading ,[object Object],[object Object],[object Object],[object Object],[object Object]
Examples of Scattered Scripts eBay MSN MySpace Wikipedia
Don't Scatter Scripts remember inline scripts carry a cost avoid long-executing inline scripts don't put inline scripts between stylesheets and other resources
Takeaways ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Steve Souders [email_address] http://stevesouders.com/
1 of 34

Recommended

@media - Even Faster Web Sites by
@media - Even Faster Web Sites@media - Even Faster Web Sites
@media - Even Faster Web SitesSteve Souders
11.5K views50 slides
Design+Performance by
Design+PerformanceDesign+Performance
Design+PerformanceSteve Souders
4.9K views67 slides
Web Directions South - Even Faster Web Sites by
Web Directions South - Even Faster Web SitesWeb Directions South - Even Faster Web Sites
Web Directions South - Even Faster Web SitesSteve Souders
2.8K views56 slides
High Performance Mobile (SF/SV Web Perf) by
High Performance Mobile (SF/SV Web Perf)High Performance Mobile (SF/SV Web Perf)
High Performance Mobile (SF/SV Web Perf)Steve Souders
18.6K views68 slides
High Performance HTML5 (SF HTML5 UG) by
High Performance HTML5 (SF HTML5 UG)High Performance HTML5 (SF HTML5 UG)
High Performance HTML5 (SF HTML5 UG)Steve Souders
15.3K views43 slides
High Performance Web Components by
High Performance Web ComponentsHigh Performance Web Components
High Performance Web ComponentsSteve Souders
6.2K views63 slides

More Related Content

What's hot

Souders WPO Web2.0Expo by
Souders WPO Web2.0ExpoSouders WPO Web2.0Expo
Souders WPO Web2.0Expoguest0b3d92d
421 views39 slides
JavaScript Performance (at SFJS) by
JavaScript Performance (at SFJS)JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)Steve Souders
22.8K views49 slides
How fast are we going now? by
How fast are we going now?How fast are we going now?
How fast are we going now?Steve Souders
37.5K views62 slides
do u webview? by
do u webview?do u webview?
do u webview?Steve Souders
7.1K views41 slides
State of the resource timing api by
State of the resource timing apiState of the resource timing api
State of the resource timing apiAaron Peters
4.7K views21 slides
Website performance optimisation by
Website performance optimisationWebsite performance optimisation
Website performance optimisationWebstock
1.1K views45 slides

What's hot(20)

Souders WPO Web2.0Expo by guest0b3d92d
Souders WPO Web2.0ExpoSouders WPO Web2.0Expo
Souders WPO Web2.0Expo
guest0b3d92d421 views
JavaScript Performance (at SFJS) by Steve Souders
JavaScript Performance (at SFJS)JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)
Steve Souders22.8K views
How fast are we going now? by Steve Souders
How fast are we going now?How fast are we going now?
How fast are we going now?
Steve Souders37.5K views
State of the resource timing api by Aaron Peters
State of the resource timing apiState of the resource timing api
State of the resource timing api
Aaron Peters4.7K views
Website performance optimisation by Webstock
Website performance optimisationWebsite performance optimisation
Website performance optimisation
Webstock1.1K views
High Performance JavaScript (Amazon DevCon 2011) by Nicholas Zakas
High Performance JavaScript (Amazon DevCon 2011)High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)
Nicholas Zakas4.6K views
Mobile Web Speed Bumps by Nicholas Zakas
Mobile Web Speed BumpsMobile Web Speed Bumps
Mobile Web Speed Bumps
Nicholas Zakas13.4K views
Preconnect, prefetch, prerender... by MilanAryal
Preconnect, prefetch, prerender...Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...
MilanAryal2.4K views
Web Performance Optimierung - DWX13 by Walter Ebert
Web Performance Optimierung - DWX13Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13
Walter Ebert7.9K views
Progressive Enhancement 2.0 (Conference Agnostic) by Nicholas Zakas
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)
Nicholas Zakas42.5K views
Web20expo 20080425 by Media Gorod
Web20expo 20080425Web20expo 20080425
Web20expo 20080425
Media Gorod392 views
WordPress common SEO issues by Olesia Korobka by Anton Shulke
WordPress common SEO issues by Olesia KorobkaWordPress common SEO issues by Olesia Korobka
WordPress common SEO issues by Olesia Korobka
Anton Shulke1.3K views
[jqconatx] Adaptive Images for Responsive Web Design by Christopher Schmitt
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design
Christopher Schmitt31.4K views
High Performance Websites by Parham
High Performance WebsitesHigh Performance Websites
High Performance Websites
Parham 1.2K views
What does the browser pre-loader do? by Andy Davies
What does the browser pre-loader do?What does the browser pre-loader do?
What does the browser pre-loader do?
Andy Davies10.7K views
10 Tips to make your Website lightning-fast - SMX Stockholm 2012 by Bastian Grimm
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
Bastian Grimm6.4K views

Similar to Web 2.0 Expo: Even Faster Web Sites

Widget Summit 2008 by
Widget Summit 2008Widget Summit 2008
Widget Summit 2008Volkan Unsal
778 views52 slides
Google在Web前端方面的经验 by
Google在Web前端方面的经验Google在Web前端方面的经验
Google在Web前端方面的经验yiditushe
1.2K views69 slides
Sxsw 20090314 by
Sxsw 20090314Sxsw 20090314
Sxsw 20090314guestcabcf63
726 views69 slides
SXSW: Even Faster Web Sites by
SXSW: Even Faster Web SitesSXSW: Even Faster Web Sites
SXSW: Even Faster Web SitesSteve Souders
9.4K views69 slides
Sanjeev ghai 12 by
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12Praveen kumar
450 views50 slides
Even Faster Web Sites at jQuery Conference '09 by
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Steve Souders
1.2K views66 slides

Similar to Web 2.0 Expo: Even Faster Web Sites(20)

Google在Web前端方面的经验 by yiditushe
Google在Web前端方面的经验Google在Web前端方面的经验
Google在Web前端方面的经验
yiditushe1.2K views
SXSW: Even Faster Web Sites by Steve Souders
SXSW: Even Faster Web SitesSXSW: Even Faster Web Sites
SXSW: Even Faster Web Sites
Steve Souders9.4K views
Even Faster Web Sites at jQuery Conference '09 by Steve Souders
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09
Steve Souders1.2K views
Fast by Default by Abhay Kumar
Fast by DefaultFast by Default
Fast by Default
Abhay Kumar3.5K views
Csdn Drdobbs Tenni Theurer Yahoo by guestb1b95b
Csdn Drdobbs Tenni Theurer YahooCsdn Drdobbs Tenni Theurer Yahoo
Csdn Drdobbs Tenni Theurer Yahoo
guestb1b95b4.3K views
Fronteers 20091105 (1) by guestbf04d7
Fronteers 20091105 (1)Fronteers 20091105 (1)
Fronteers 20091105 (1)
guestbf04d73.4K views
Defeating Cross-Site Scripting with Content Security Policy (updated) by Francois Marier
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)
Francois Marier3.3K views
A Holistic View of Website Performance by Rene Churchill
A Holistic View of Website PerformanceA Holistic View of Website Performance
A Holistic View of Website Performance
Rene Churchill1K views
High Performance Web Pages - 20 new best practices by Stoyan Stefanov
High Performance Web Pages - 20 new best practicesHigh Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practices
Stoyan Stefanov50.1K views
腾讯大讲堂09 如何建设高性能网站 by areyouok
腾讯大讲堂09 如何建设高性能网站腾讯大讲堂09 如何建设高性能网站
腾讯大讲堂09 如何建设高性能网站
areyouok372 views
腾讯大讲堂09 如何建设高性能网站 by topgeek
腾讯大讲堂09 如何建设高性能网站腾讯大讲堂09 如何建设高性能网站
腾讯大讲堂09 如何建设高性能网站
topgeek1.3K views
Developing High Performance Web Apps - CodeMash 2011 by Timothy Fisher
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
Timothy Fisher9.6K views
Even Faster Web Sites at The Ajax Experience by Steve Souders
Even Faster Web Sites at The Ajax ExperienceEven Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax Experience
Steve Souders1.2K views
Testable client side_mvc_apps_in_javascript by Timothy Oxley
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
Timothy Oxley1.2K views
Developing High Performance Web Apps by Timothy Fisher
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
Timothy Fisher1.3K views
Google I/O 2012 - Protecting your user experience while integrating 3rd party... by Patrick Meenan
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...
Patrick Meenan3K views

More from Steve Souders

Make JavaScript Faster by
Make JavaScript FasterMake JavaScript Faster
Make JavaScript FasterSteve Souders
2.9K views47 slides
Metrics of Joy by
Metrics of JoyMetrics of Joy
Metrics of JoySteve Souders
2.8K views34 slides
The Perception of Speed by
The Perception of SpeedThe Perception of Speed
The Perception of SpeedSteve Souders
4.1K views40 slides
High Performance Web Components by
High Performance Web ComponentsHigh Performance Web Components
High Performance Web ComponentsSteve Souders
10.3K views45 slides
Cache is King by
Cache is KingCache is King
Cache is KingSteve Souders
6.6K views70 slides
High Performance Snippets by
High Performance SnippetsHigh Performance Snippets
High Performance SnippetsSteve Souders
5.9K views33 slides

More from Steve Souders(11)

Make JavaScript Faster by Steve Souders
Make JavaScript FasterMake JavaScript Faster
Make JavaScript Faster
Steve Souders2.9K views
The Perception of Speed by Steve Souders
The Perception of SpeedThe Perception of Speed
The Perception of Speed
Steve Souders4.1K views
High Performance Web Components by Steve Souders
High Performance Web ComponentsHigh Performance Web Components
High Performance Web Components
Steve Souders10.3K views
High Performance Snippets by Steve Souders
High Performance SnippetsHigh Performance Snippets
High Performance Snippets
Steve Souders5.9K views
Your Script Just Killed My Site by Steve Souders
Your Script Just Killed My SiteYour Script Just Killed My Site
Your Script Just Killed My Site
Steve Souders10.5K views
Souders WPO Web 2.0 Expo by Steve Souders
Souders WPO Web 2.0 ExpoSouders WPO Web 2.0 Expo
Souders WPO Web 2.0 Expo
Steve Souders6.9K views
Browserscope Launch at TAE by Steve Souders
Browserscope Launch at TAEBrowserscope Launch at TAE
Browserscope Launch at TAE
Steve Souders708 views

Recently uploaded

Democratising digital commerce in India-Report by
Democratising digital commerce in India-ReportDemocratising digital commerce in India-Report
Democratising digital commerce in India-ReportKapil Khandelwal (KK)
15 views161 slides
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...James Anderson
85 views32 slides
Five Things You SHOULD Know About Postman by
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
33 views43 slides
Ransomware is Knocking your Door_Final.pdf by
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdfSecurity Bootcamp
55 views46 slides
Special_edition_innovator_2023.pdf by
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdfWillDavies22
17 views6 slides
STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
14 views1 slide

Recently uploaded(20)

GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson85 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman33 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2217 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada127 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker37 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst478 views
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn22 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri16 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta26 views

Web 2.0 Expo: Even Faster Web Sites

  • 1. Steve Souders [email_address] http://stevesouders.com/ Even Faster Web Sites best practices for faster pages Disclaimer: This content does not necessarily reflect the opinions of my employer.
  • 2. The Importance of Frontend Performance 17% 83% iGoogle, primed cache 9% 91% iGoogle, empty cache
  • 3. Time Spent on the Frontend Empty Cache Primed Cache www.aol.com 97% 97% www.ebay.com 95% 81% www.facebook.com 95% 81% www.google.com/search 47% 0% search.live.com/results 67% 0% www.msn.com 98% 94% www.myspace.com 98% 98% en.wikipedia.org/wiki 94% 91% www.yahoo.com 97% 96% www.youtube.com 98% 97%
  • 4. The Performance Golden Rule 80-90% of the end-user response time is spent on the frontend. Start there. greater potential for improvement simpler proven to work
  • 5.
  • 6. High Performance Web Sites YSlow
  • 7.
  • 8.
  • 9. Why focus on JavaScript? AOL eBay Facebook MySpace Wikipedia Yahoo! YouTube
  • 10. Scripts Block <script src=&quot;A.js&quot;> blocks parallel downloads and rendering What's &quot;Cuzillion&quot;? http://stevesouders.com/cuzillion/?ex=10008
  • 11. Cuzillion 'cuz there are a zillion pages to check a tool for quickly constructing web pages to see how components interact Open Source http://stevesouders.com/cuzillion/
  • 12. Split the Initial Payload: Facebook 43 external scripts, 550K uncompressed 9% of functionality is used before onload
  • 13. Unexecuted Payload 73.6% avg functions not used before onload www.aol.com 70% www.ebay.com 56% www.facebook.com 91% www.google.com/search 55% search.live.com/results 76% www.msn.com 69% www.myspace.com 82% en.wikipedia.org/wiki 68% www.yahoo.com 87% www.youtube.com 82%
  • 14. Split the initial payload split your JavaScript between what's needed to render the page and everything else load &quot;everything else&quot; after the page is rendered separate manually (Firebug); tools needed to automate this (Doloto from Microsoft) load scripts without blocking – how?
  • 15. MSN.com: Parallel Scripts Scripts and other resources downloaded in parallel! How? var p=g.getElementsByTagName(&quot;HEAD&quot;)[0]; var c=g.createElement(&quot;script&quot;); c.type=&quot;text/javascript&quot;; c.onreadystatechange=n; c.onerror=c.onload=k; c.src=e; p.appendChild(c) MSN
  • 16. Advanced Script Loading XHR Eval XHR Injection Script in Iframe Script DOM Element Script Defer document.write Script Tag
  • 17. XHR Eval script must have same domain as main page must refactor script var xhrObj = getXHRObject(); xhrObj.onreadystatechange = function() { if ( xhrObj.readyState != 4 ) return; eval(xhrObj.responseText); }; xhrObj.open('GET', 'A.js', true); xhrObj.send(''); http://stevesouders.com/cuzillion/?ex=10009
  • 18. XHR Injection var xhrObj = getXHRObject(); xhrObj.onreadystatechange = function() { if ( xhrObj.readyState != 4 ) return; var se=document.createElement('script'); document.getElementsByTagName('head') [0].appendChild(se); se.text = xhrObj.responseText; }; xhrObj.open('GET', 'A.js', true); xhrObj.send(''); script must have same domain as main page http://stevesouders.com/cuzillion/?ex=10015
  • 19.
  • 20. Script DOM Element var se = document.createElement('script'); se.src = 'http://anydomain.com/A.js'; document.getElementsByTagName('head') [0].appendChild(se); script and main page domains can differ no need to refactor JavaScript http://stevesouders.com/cuzillion/?ex=10010
  • 21. Script Defer <script defer src='A.js'></script> only supported in IE script and main page domains can differ no need to refactor JavaScript http://stevesouders.com/cuzillion/?ex=10013
  • 22. document.write Script Tag document.write (&quot;<scri&quot; + &quot;ipt type='text/javascript' src='A.js'>&quot; + &quot;</scri&quot; + &quot;ipt>&quot;); parallelization only works in IE parallel downloads for scripts, nothing else all document.write s must be in same script block http://stevesouders.com/cuzillion/?ex=10014
  • 24. Browser Busy Indicators good to show busy indicators when the user needs feedback bad when downloading in the background
  • 25.
  • 26. Summary of Traits * Only other document.write scripts are downloaded in parallel (in the same script block).
  • 27. and the winner is...
  • 28.
  • 29.
  • 30.
  • 31. Examples of Scattered Scripts eBay MSN MySpace Wikipedia
  • 32. Don't Scatter Scripts remember inline scripts carry a cost avoid long-executing inline scripts don't put inline scripts between stylesheets and other resources
  • 33.
  • 34. Steve Souders [email_address] http://stevesouders.com/

Editor's Notes

  1. Permission to use photo given by Amnemona: http://www.flickr.com/photos/marinacvinhal/379111290/