SlideShare a Scribd company logo
1 of 42
High Performance Ajax Applications Julien Lecomte http://www.julienlecomte.net/blogfiles/performance/ajax-perf.ppt http://www.slideshare.net/julien.lecomte/high-performance-ajax-applications
Part 1 Developing For High Performance
Planning and designing for high performance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Engineering high performance: A few basic rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Measuring performance ,[object Object],[object Object],[object Object],[object Object],[object Object]
Part 2 High Performance Page Load
Yahoo!'s Exceptional Performance 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],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Asset optimization ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reduce unminified code size ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Optimize initial rendering (1/4) Miscellaneous tips... ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Optimize initial rendering (2/4) Don’t always wait for  onload ... ,[object Object],[object Object],[object Object],YAHOO.util.Event.onDOMReady( function  () { // Do something here... // e.g., attach event handlers. });
Optimize initial rendering (3/4) Post-load script loading ,[object Object],[object Object],[object Object],[object Object],[object Object],<script> window.onload =  function  () { var  script = document.createElement( &quot;script&quot; ); script.src = ...; document.body.appendChild(script); }; </script>
Optimize initial rendering (4/4) Conditional preloading ,[object Object],[object Object],[object Object],[object Object]
Part 3 High Performance JavaScript
Reduce the amount of symbolic look-up: The scope chain (1/2) var  g =  7 ; function  f(a) { var  v =  8 ; x = v + a + g; } f(6); parent ,[object Object],[object Object]
Reduce the amount of symbolic look-up: The scope chain (2/2) ,[object Object],[object Object],[object Object],var  arr = ...; var  globalVar =  0 ; ( function  () { var  i; for (i =  0 ; i < arr.length; i++) { globalVar++; } })(); var  arr = ...; var  globalVar =  0 ; ( function  () { var  i, l, localVar; l = arr.length; localVar = globalVar; for (i =  0 ; i < l; i++) { localVar++; } globalVar = localVar; })(); (faster on all A-grade browsers)
Reduce the amount of symbolic look-up: The prototype chain function  A () {} A.prototype.prop1 = ...; function  B () { this .prop2 = ...; } B.prototype =  new  A(); var  b =  new  B(); B.prototype ,[object Object],[object Object]
Optimize object instantiation ,[object Object],[object Object],[object Object],function  Foo () {...} Foo.prototype.bar =  function  () {...}; function  Foo () { this .bar =  function  () {...}; }
Don’t use  eval ! ,[object Object],[object Object],setTimeout( function  () { // Code to execute on a timeout },  50 ); ,[object Object]
Optimize string concatenation ,[object Object],var  s =  “xxx”  +  “yyy” ; s +=  “zzz” ; ,[object Object],var  i, s =  “” ; for (i =  0 ; i <  10000 ; i++) { s +=  “x” ; } var  i, s = []; for (i =  0 ; i <  10000 ; i++) { s[i] =  “x” ; } s = s.join( “” ); ,[object Object],[object Object]
Optimize regular expressions ,[object Object],[object Object],[object Object],[object Object],if ( /loaded|complete/ .test(document.readyState)) {...} (?:(?:)?[])*(?:(?:(?:[^()<>@,;:&quot;.00-31]+(?:(?:(?:)?[])+||(?=[&quot;()<>@,;:&quot;.]))|&quot; (?:[^amp;quot;]|.|(?:(?:)?[]))*&quot;(?:(?:)?[])*)(?:(?:(?:)?[])*(?:[^()<>@,;:&quot;.00-31 ]+(?:(?:(?:)?[])+||(?=[&quot;()<>@,;:&quot;.]))|&quot;(?:[^amp;quot;]|.|(?:(?:)?[]))*&quot;(?:(?:)?[]) *))*@(?:(?:)?[])*(?:[^()<>@,;:&quot;.00-31]+(?:(?:(?:)?[])+||(?=[&quot;()<>@,;:&quot;.]))| ([^]|.)*(?:(?:)?[])*)(?:(?:(?:)?[])*(?:[^()<>@,;:&quot;.00-31]+(?:(?:(?:)? [])+||(?=[&quot;()<>@,;:&quot;.]))|([^]|.)*(?:(?:)?[])*))*|(?:[^()<>@,;:&quot;.00- 31]+(?:(?:(?:)?[])+||(?=[&quot;()<>@,;:&quot;.]))|&quot;(?:[^amp;quot;]|.|(?:(?:)?[]))*&quot;(?:(?:)?[ ])*)*lt;(?:(?:)?[])*(?:@(?:[^()<>@,;:&quot;.00-31]+(?:(?:(?:)?[])+||(?=[&quot;()<>@,;:&quot;. ]))|([^]|.)*(?:(?:)?[])*)(?:(?:(?:)?[])*(?:[^()<>@,;:&quot;.00-31]+(?:(?:(?: )?[])+||(?=[&quot;()<>@,;:&quot;.]))|([^]|.)*(?:(?:)?[])*))*(?:,@(?:(?:)?[]))
Caching ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],var  fn = ( function  () { var  b =  false , v; return   function  () { if  (!b) { v = ...; b =  true ; } return  v; }; })(); function  fn () { if  (!fn.b) { fn.v = ...; fn.b =  true ; } return  fn.v; } var  fn =  function  () { var  v = ...; return  (fn =  function  () { return  v; })(); }; Module pattern Store value in function object Lazy function definition
How to handle long running JavaScript processes (1/2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How to handle long running JavaScript processes (2/2) function  doSomething (callbackFn) { // Initialize a few things here... ( function  () { // Do a little bit of work here... if  ( termination condition ) { // We are done callbackFn(); }  else  { // Process next chunk setTimeout(arguments.callee, 0); } })(); }
Miscellaneous tips (1/2) ,[object Object],var  a =  1 , b =  2 , c; c = Math.min(a, b); c = a < b ? a : b; ,[object Object],var  i; for  (i =  0 ; i <  100000 ; i++) { try  { ... }  catch  (e) { ... } } var  i; try  { for  (i =  0 ; i <  100000 ; i++) { ... } }  catch  (e) { ... } myArray.push(value); myArray[myArray.length] = value; myArray[idx++] = value;
Miscellaneous tips (2/2) ,[object Object],var  key, value; for  (key in myArray) { value = myArray[key]; ... } var  i, value, length = myArray.length; for  (i =  0 ; i < length; i++) { value = myArray[i]; ... } ,[object Object],function  fn () { if  (...) { ... }  else  { ... } } var  fn; if  (...) { fn =  function  () {...}; }  else  { fn =  function  () {...}; }
Part 4 High Performance Dynamic HTML
Document tree modification Using  innerHTML var  i, j, el, table, tbody, row, cell; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); table = document.createElement( &quot;table&quot; ); el.appendChild(table); tbody = document.createElement( &quot;tbody&quot; ); table.appendChild(tbody); for  (i =  0 ; i <  1000 ; i++) { row = document.createElement( &quot;tr&quot; ); for  (j =  0 ; j <  5 ; j++) { cell = document.createElement( &quot;td&quot; ); row.appendChild(cell); } tbody.appendChild(row); } var  i, j, el, idx, html; idx =  0 ; html = []; html[idx++] =  &quot;<table>&quot; ; for  (i =  0 ; i <  1000 ; i++) { html[idx++] =  &quot;<tr>&quot; ; for  (j =  0 ; j <  5 ; j++) { html[idx++] =  &quot;<td></td>&quot; ; } html[idx++] =  &quot;</tr>&quot; ; } html[idx++] =  &quot;</table>&quot; ; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); el.innerHTML = html.join( &quot;&quot; ); ( much  faster on all A-grade browsers) Warning: See  http://www.julienlecomte.net/blog/2007/12/38/
Document tree modification Using  cloneNode var  i, j, el, table, tbody, row, cell; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); table = document.createElement( &quot;table&quot; ); el.appendChild(table); tbody = document.createElement( &quot;tbody&quot; ); table.appendChild(tbody); for  (i =  0 ; i <  1000 ; i++) { row = document.createElement( &quot;tr&quot; ); for  (j =  0 ; j <  5 ; j++) { cell = document.createElement( &quot;td&quot; ); row.appendChild(cell); } tbody.appendChild(row); } var  i, el, table, tbody, template, row, cell; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); table = document.createElement( &quot;table&quot; ); el.appendChild(table); tbody = document.createElement( &quot;tbody&quot; ); table.appendChild(tbody); template = document.createElement( &quot;tr&quot; ); for  (i =  0 ; i <  5 ; i++) { cell = document.createElement( &quot;td&quot; ); template.appendChild(cell); } for  (i =  0 ; i <  1000 ; i++) { row = template.cloneNode(true); tbody.appendChild(row); } (faster on all A-grade browsers – sometimes  much  faster) Warning: expando properties/attached event handlers are lost!
Document tree modification Using DocumentFragment ,[object Object],[object Object],[object Object],var  i, j, el, table, tbody, row, cell, docFragment; docFragment = document.createDocumentFragment(); el = document.createElement( &quot;div&quot; ); docFragment.appendChild(el); table = document.createElement( &quot;table&quot; ); el.appendChild(table); tbody = document.createElement( &quot;tbody&quot; ); table.appendChild(tbody); for  (i =  0 ; i <  1000 ; i++) { ... } document.body.appendChild(docFragment);
Limit the number of event handlers (1/2) ,[object Object],[object Object],[object Object],<div id= &quot;container&quot; > <ul> <li id= &quot;li-1&quot; > List Item 1 </li> <li id= &quot;li-2&quot; > List Item 2 </li> <li id= &quot;li-3&quot; > List Item 3 </li> <li id= &quot;li-4&quot; > List Item 4 </li> <li id= &quot;li-5&quot; > List Item 5 </li> ... </ul> </div> div#container ul li#li- x text node
Limit the number of event handlers (2/2) YAHOO.util.Event.addListener( &quot;container&quot; ,  &quot;click&quot; ,  function  (e) { var  el = YAHOO.util.Event.getTarget(e); while (el.id !==  &quot;container&quot; ) { if (el.nodeName.toUpperCase() ===  &quot;LI&quot; ) { // Do something here... break; } else { el = el.parentNode; } } });
Limiting reflows ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],el.style.cssText =  &quot;display:block;width:auto;height:100px;...&quot; ; YAHOO.util.Dom.replaceClass(el,  &quot;foo&quot; ,  &quot;bar&quot; ); el.setAttribute( &quot;style&quot; ,  &quot;display:block;width:auto;height:100px;...&quot; );
Miscellaneous tips... ,[object Object],[object Object],[object Object],[object Object]
Part 5 High Performance Layout and CSS
Miscellaneous tips... ,[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],[object Object]
Part 6 High Performance Ajax
Ajax Best Practices ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],var  callback = { success:  function  () {  /* Do something */  }, failure:  function  () {  /* Do something */  }, timeout:  5000 }; YAHOO.util.Connect.asyncRequest( &quot;GET&quot; , url, callback);
Improving perceived network latency using the optimistic pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Miscellaneous tips... ,[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]
Part 7 Performance Tools
Performance Tools ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Fwdays
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slidesDavid Barreto
 
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"Fwdays
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript TestingRan Mizrahi
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play appsYevgeniy Brikman
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing ComplexityRyan Anklam
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaExoLeaders.com
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?Robert Munteanu
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Fabien Potencier
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with seleniumSøren Lund
 

What's hot (19)

Thomas Fuchs Presentation
Thomas Fuchs PresentationThomas Fuchs Presentation
Thomas Fuchs Presentation
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slides
 
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
 
Let's migrate to Swift 3.0
Let's migrate to Swift 3.0Let's migrate to Swift 3.0
Let's migrate to Swift 3.0
 
Dan Webb Presentation
Dan Webb PresentationDan Webb Presentation
Dan Webb Presentation
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play apps
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
 
Zenly - Reverse geocoding
Zenly - Reverse geocodingZenly - Reverse geocoding
Zenly - Reverse geocoding
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?
 
OHHttpStubs
OHHttpStubsOHHttpStubs
OHHttpStubs
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with selenium
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 

Viewers also liked

Viewers also liked (20)

Acomer
AcomerAcomer
Acomer
 
De achtbaan der E Commerce 2.0: Losing control(oude versie)
De achtbaan der E Commerce 2.0: Losing control(oude versie)De achtbaan der E Commerce 2.0: Losing control(oude versie)
De achtbaan der E Commerce 2.0: Losing control(oude versie)
 
Tirrell
TirrellTirrell
Tirrell
 
Copyleft
CopyleftCopyleft
Copyleft
 
Copyleft project
Copyleft projectCopyleft project
Copyleft project
 
Cuento De Hadas 2
Cuento De Hadas 2Cuento De Hadas 2
Cuento De Hadas 2
 
China Winter Snow 1
China Winter Snow 1China Winter Snow 1
China Winter Snow 1
 
EI Tibet
EI TibetEI Tibet
EI Tibet
 
Fuerza
FuerzaFuerza
Fuerza
 
Faq Alice
Faq AliceFaq Alice
Faq Alice
 
Escoex Publicidad Elanunciante Dia Uno
Escoex Publicidad Elanunciante Dia UnoEscoex Publicidad Elanunciante Dia Uno
Escoex Publicidad Elanunciante Dia Uno
 
Iranian Look Alikes
Iranian Look AlikesIranian Look Alikes
Iranian Look Alikes
 
Copyleft
CopyleftCopyleft
Copyleft
 
EdTech Powerpoint
EdTech PowerpointEdTech Powerpoint
EdTech Powerpoint
 
China's Worst snowstorm
China's Worst snowstorm China's Worst snowstorm
China's Worst snowstorm
 
internet oggi..e domani
internet oggi..e domaniinternet oggi..e domani
internet oggi..e domani
 
Convergencia de la Seguridad
Convergencia de la SeguridadConvergencia de la Seguridad
Convergencia de la Seguridad
 
Web 2.0 E Oltre
Web 2.0 E OltreWeb 2.0 E Oltre
Web 2.0 E Oltre
 
Mi viaje a Irlanda
Mi viaje a IrlandaMi viaje a Irlanda
Mi viaje a Irlanda
 
Pdiusbd11
Pdiusbd11Pdiusbd11
Pdiusbd11
 

Similar to High Performance Ajax Applications 1197671494632682 2

Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupDavid Barreto
 
Silicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NET
Silicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NETSilicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NET
Silicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NETMats Bryntse
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's Howmrdon
 
My 70-480 HTML5 certification learning
My 70-480 HTML5 certification learningMy 70-480 HTML5 certification learning
My 70-480 HTML5 certification learningSyed Irtaza Ali
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performancekaven yan
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceSebastian Springer
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web AppsTimothy Fisher
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitAlex Chaffee
 
Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)Artur Cistov
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than YouRobert Cooper
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performanceAbhishek Sur
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web PerformanceAdam Lu
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppKaty Slemon
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingHoat Le
 

Similar to High Performance Ajax Applications 1197671494632682 2 (20)

Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
Silicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NET
Silicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NETSilicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NET
Silicon Valley CodeCamp 2008: High performance Ajax with ExtJS and ASP.NET
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
My 70-480 HTML5 certification learning
My 70-480 HTML5 certification learningMy 70-480 HTML5 certification learning
My 70-480 HTML5 certification learning
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performance
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web Performance
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
 
Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
 
backend
backendbackend
backend
 
backend
backendbackend
backend
 

Recently uploaded

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

High Performance Ajax Applications 1197671494632682 2

  • 1. High Performance Ajax Applications Julien Lecomte http://www.julienlecomte.net/blogfiles/performance/ajax-perf.ppt http://www.slideshare.net/julien.lecomte/high-performance-ajax-applications
  • 2. Part 1 Developing For High Performance
  • 3.
  • 4.
  • 5.
  • 6. Part 2 High Performance Page Load
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Part 3 High Performance JavaScript
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. How to handle long running JavaScript processes (2/2) function doSomething (callbackFn) { // Initialize a few things here... ( function () { // Do a little bit of work here... if ( termination condition ) { // We are done callbackFn(); } else { // Process next chunk setTimeout(arguments.callee, 0); } })(); }
  • 25.
  • 26.
  • 27. Part 4 High Performance Dynamic HTML
  • 28. Document tree modification Using innerHTML var i, j, el, table, tbody, row, cell; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); table = document.createElement( &quot;table&quot; ); el.appendChild(table); tbody = document.createElement( &quot;tbody&quot; ); table.appendChild(tbody); for (i = 0 ; i < 1000 ; i++) { row = document.createElement( &quot;tr&quot; ); for (j = 0 ; j < 5 ; j++) { cell = document.createElement( &quot;td&quot; ); row.appendChild(cell); } tbody.appendChild(row); } var i, j, el, idx, html; idx = 0 ; html = []; html[idx++] = &quot;<table>&quot; ; for (i = 0 ; i < 1000 ; i++) { html[idx++] = &quot;<tr>&quot; ; for (j = 0 ; j < 5 ; j++) { html[idx++] = &quot;<td></td>&quot; ; } html[idx++] = &quot;</tr>&quot; ; } html[idx++] = &quot;</table>&quot; ; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); el.innerHTML = html.join( &quot;&quot; ); ( much faster on all A-grade browsers) Warning: See http://www.julienlecomte.net/blog/2007/12/38/
  • 29. Document tree modification Using cloneNode var i, j, el, table, tbody, row, cell; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); table = document.createElement( &quot;table&quot; ); el.appendChild(table); tbody = document.createElement( &quot;tbody&quot; ); table.appendChild(tbody); for (i = 0 ; i < 1000 ; i++) { row = document.createElement( &quot;tr&quot; ); for (j = 0 ; j < 5 ; j++) { cell = document.createElement( &quot;td&quot; ); row.appendChild(cell); } tbody.appendChild(row); } var i, el, table, tbody, template, row, cell; el = document.createElement( &quot;div&quot; ); document.body.appendChild(el); table = document.createElement( &quot;table&quot; ); el.appendChild(table); tbody = document.createElement( &quot;tbody&quot; ); table.appendChild(tbody); template = document.createElement( &quot;tr&quot; ); for (i = 0 ; i < 5 ; i++) { cell = document.createElement( &quot;td&quot; ); template.appendChild(cell); } for (i = 0 ; i < 1000 ; i++) { row = template.cloneNode(true); tbody.appendChild(row); } (faster on all A-grade browsers – sometimes much faster) Warning: expando properties/attached event handlers are lost!
  • 30.
  • 31.
  • 32. Limit the number of event handlers (2/2) YAHOO.util.Event.addListener( &quot;container&quot; , &quot;click&quot; , function (e) { var el = YAHOO.util.Event.getTarget(e); while (el.id !== &quot;container&quot; ) { if (el.nodeName.toUpperCase() === &quot;LI&quot; ) { // Do something here... break; } else { el = el.parentNode; } } });
  • 33.
  • 34.
  • 35. Part 5 High Performance Layout and CSS
  • 36.
  • 37. Part 6 High Performance Ajax
  • 38.
  • 39.
  • 40.
  • 42.