SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
JavaScript Performance
You like it, it likes you!

Rodrigo Castilho aka RODCAST
Senior Front End Engineer
@rodcast

3/29/2012




                               /1
Sad But True




               /2
I'm your pain

  • Frontend is responsible for most of the performance
    Around 90% of the end-user response time is spent on the frontend.


  • What worked in the past, may not work today


  • Consumers are less tolerant than ever


  • Premature optimization is the root of all evil




                                                                         /3
I'm your pain

  • Frontend is responsible for most of the performance


  • What worked in the past, may not work today
    Books demonstrate that there’s stuff that may not work in modern browsers
    because the browsers are in constant changes.


  • Consumers are less tolerant than ever


  • Premature optimization is the root of all evil




                                                                                /4
I'm your pain

  • Frontend is responsible for most of the performance


  • What worked in the past, may not work today


  • Consumers are less tolerant than ever
    The consumers find bad performance unacceptable. They want websites to perform
    well during peak periods.


  • Premature optimization is the root of all evil




                                                                                /5
I'm your pain

  • Frontend is responsible for most of the performance


  • What worked in the past, may not work today


  • Consumers are less tolerant than ever


  • Premature optimization is the root of all evil
    Avoiding poor quality coding can also improve performance, by avoiding obvious
    "slowdowns".




                                                                                     /6
Assigned books




                 /7
Know Your Enemy




                  /8
Come on

 • Browser wars
   The function that runs lightning fast on one browser may perform sluggishly on
   another.


 • Use the latest version of jQuery


 • Plugins, plugins and more plugins


 • HTML and CSS (They are also very important)




                                                                                    /9
Come on

 • Browser wars


 • Use the latest version of jQuery
   The newest version is usually the best one. Also don’t forget to test your code after
   changing your jQuery core version.


 • Plugins, plugins and more plugins


 • HTML and CSS (They are also very important)




                                                                                       / 10
Come on

 • Browser wars


 • Use the latest version of jQuery


 • Plugins, plugins and more plugins
   Be careful with them, they can be evil.


 • HTML and CSS (They are also very important)




                                                 / 11
Come on

 • Browser wars


 • Use the latest version of jQuery


 • Plugins, plugins and more plugins


 • HTML and CSS (They are also very important)
   JavaScript doesn't work alone it also needs a set of other things for it to load faster.
   Validate your HTML and don't forget to test your pages.




                                                                                         / 12
Browser wars
  • V8 by Chrome

  • TraceMonkey by Firefox

  • SquirrelFish by Safari

  • JScript by Internet Explorer
                                   / 13
Paranoid




           / 14
Nothing seems to satisfy

  • 1 byte or 1ms is very precious.


  • Persistency is the key to a better user experience.


  • Let me give some examples with Expressions and Operators:


      • Chain, comparison, condition, special, bitwise, logical OR/AND…




                                                                          / 15
Var, var, var…




                 / 16
Logical operator




                   / 17
Logical operator




                   / 18
Special operator




                   / 19
Bitwise operator




                   / 20
Cache… all the time




                      / 21
Stewie Griffin
  I'm sure he was thinking of Internet Explorer.




                                                   / 22
The Evil That Men Do




                       / 23
Living on the razor's edge

  • Use HTML 5
    The new HTML5 standard comes with a lighter DOM structure in mind. Lighter
    DOM structure means less elements to traverse for jQuery and better load
    performance. So, switch to it whenever it's possible.


  • Best Practices for a Faster Web App with HTML5


  • Load content On-Demand (Lazy Load)


  • Use the correct method .bind() vs .live() vs .delegate() vs .on()


  • Change CSS classes not styles


                                                                                 / 24
Living on the razor's edge

  • Use HTML 5


  • Best Practices for a Faster Web App with HTML5
    Use web storage in place of cookies.
    Use CSS Transitions instead of JavaScript animation.
    Use client-side databases instead of server round-trips.


  • Load content On-Demand (Lazy Load)


  • Use the correct method .bind() vs .live() vs .delegate() vs .on()


  • Change CSS classes not styles


                                                                        / 25
Living on the razor's edge

  • Use HTML 5


  • Best Practices for a Faster Web App with HTML5


  • Load content On-Demand (Lazy Load)
    An AJAX pattern is to load JavaScript dynamically or when the user runs a feature that requires
    your script.


  • Use the correct method .bind() vs .live() vs .delegate() vs .on()


  • Change CSS classes not styles




                                                                                                 / 26
Living on the razor's edge

  • Use HTML 5


  • Best Practices for a Faster Web App with HTML5


  • Load content On-Demand (Lazy Load)


  • Use the correct method .bind() vs .live() vs .delegate() vs .on()
    With jQuery 1.7, new method that you should use is on() is the combination of bind,
    live and delegate method.


  • Change CSS classes not styles



                                                                                     / 27
Living on the razor's edge

  • Use HTML 5


  • Best Practices for a Faster Web App with HTML5


  • Load content On-Demand (Lazy Load)


  • Use the correct method .bind() vs .live() vs .delegate() vs .on()


  • Change CSS classes not styles
    You may have heard that changing CSS classes is more optimal than changing
    styles.



                                                                                 / 28
Beavis and Butt-Head
  Watching the presentation.




                               / 29
Roots Bloody Roots




                     / 30
I'll take you to a place

  • Use jQuery only when it’s absolutely necessary
    Whenever possible you should not use it. Remember it’s sometimes more efficient
    to use regular JavaScript.


  • Use requestAnimationFrame instead of setInterval/setTimeout


  • Modernizr to give the user the experience expected


  • Cache Manifest (appCache)


  • Local Storage (cookies on steroids)



                                                                                  / 31
Native JavaScript is better (normally)




                                         / 32
I'll take you to a place

  • Use jQuery only when it’s absolutely necessary


  • Use requestAnimationFrame instead of setInterval/setTimeout
    It throttles the animation for inactive tabs, so it won’t sap your mobile device’s battery if you
    leave it open in the background.


  • Modernizr to give the user the experience expected


  • Cache Manifest (appCache)


  • Local Storage (cookies on steroids)




                                                                                                        / 33
I'll take you to a place

  • Use jQuery only when it’s absolutely necessary


  • Use requestAnimationFrame instead of setInterval/setTimeout


  • Modernizr to give the user the experience expected
    Modernizr is a JavaScript library that detects the features your browser can support,
    like HTML 5 and CSS3 .It let you manage what to do if the browser don't show
    something in the right way.


  • Cache Manifest (appCache)


  • Local Storage (cookies on steroids)


                                                                                      / 34
I'll take you to a place

  • Use jQuery only when it’s absolutely necessary


  • Use requestAnimationFrame instead of setInterval/setTimeout


  • Modernizr to give the user the experience expected


  • Cache Manifest (appCache)
    The application cache also persists between browser sessions. So, a web
    application that was previously used on the computer or device can continue to
    work offline - for example, when iOS has no network or is in airplane mode.


  • Local Storage (cookies on steroids)


                                                                                     / 35
Cache manifest (appCache)




                            / 36
I'll take you to a place

  • Use jQuery only when it’s absolutely necessary


  • Use requestAnimationFrame instead of setInterval/setTimeout


  • Modernizr to give the user the experience expected


  • Cache Manifest (appCache)


  • Local Storage (cookies on steroids)
    Local Storage is a dead simple API for storing information on the client side.




                                                                                     / 37
Local Storage




                / 38
Stewie Griffin
  Again, again I love repetition...

  Stewie begins taking steroids after he is beat up by a baby girl.




                                                                      / 39
Before I Forget




                  / 40
Hold your breath

  • Without bugs
    You will agree that performance is very important but "bug free" is the most
    important thing of all. Then you should fix the bugs and not forget the performance.


  • Create unit tests


  • Never forget


  • Use the powerful tools in your favor


  • JSPerf is your partner



                                                                                      / 41
Hold your breath

  • Without bugs


  • Create unit tests
    The best way to test a JavaScript code is the human way but you can still use some
    automated tools.


  • Never forget


  • Use the powerful tools in your favor


  • JSPerf is your partner



                                                                                    / 42
Hold your breath

  • Without bugs

  • Create unit tests

  • Never forget
    Make JavaScript and CSS External
    Minify JavaScript and CSS
    Make Ajax Cacheable
    Gzip Components
    Put Stylesheets at Top
    Put Scripts at Bottom
    Optimize Images and create CSS Sprites

  • Use the powerful tools in your favor

  • JSPerf is your partner


                                             / 43
Hold your breath

  • Without bugs

  • Create unit tests

  • Never forget

  • Use the powerful tools in your favor
    JSLint/JSHint, JSPerf, JSMeter, FireQuery, JS Console, FireUnit, CSS Lint, Web
    Developer, Firebug, JSView, Fiddler, HTTPFox, Live HTTP headers, YUI
    Compressor, Google Closure, Microsoft Ajax Minifier, YSlow, Google Page Speed,
    MySpace Performance Tracker, IBM Page Detailer, HTTPD Watch, Web Page
    Test, Speed Tracer, Dyna Tracer, ZocDoc, ShowSlow, Smush.it between other
    tools.

  • JSPerf is your partner



                                                                                 / 44
Hold your breath

  • Without bugs


  • Create unit tests


  • Never forget


  • Use the powerful tools in your favor


  • JSPerf is your partner
    A performance playground for JavaScript developers that allows to write your tests.




                                                                                     / 45
Homer Simpson
 WOOHOO!!! I hope I haven't forgotten anything.




                                                  / 46
Musics mentioned

  • Sad But True – Metallica


  • Know Your Enemy - Rage Against The Machine


  • Paranoid - Black Sabbath


  • The Evil That Men Do - Iron Maiden


  • Roots Bloody Roots - Sepultura


  • Before I Forget - Slipknot

                                                 / 47
Thank You.

Weitere ähnliche Inhalte

Ähnlich wie Tech Headline - JavaScript Performance

Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptTroy Miles
 
State of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront ConferenceState of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront Conferencedmethvin
 
Quo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynoteQuo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynoteChristian Heilmann
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesVolkan Özçelik
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Volkan Özçelik
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)Thinkful
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angularBasarat Syed
 
Building Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on AzureBuilding Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on AzureBrian Lyttle
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumTechday7
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Jess Coburn
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive uiPaul van Zyl
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) Volkan Özçelik
 
jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013dmethvin
 
Taking Micronaut out for a spin
Taking Micronaut out for a spinTaking Micronaut out for a spin
Taking Micronaut out for a spinAndres Almiray
 
Gwt overview & getting started
Gwt overview & getting startedGwt overview & getting started
Gwt overview & getting startedBinh Bui
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidStanojko Markovik
 

Ähnlich wie Tech Headline - JavaScript Performance (20)

Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Ajaxworld07
Ajaxworld07Ajaxworld07
Ajaxworld07
 
Ajaxworld07
Ajaxworld07Ajaxworld07
Ajaxworld07
 
State of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront ConferenceState of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront Conference
 
Quo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynoteQuo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynote
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best Practices
 
Web frameworks
Web frameworksWeb frameworks
Web frameworks
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)
 
wt mod3.pdf
wt mod3.pdfwt mod3.pdf
wt mod3.pdf
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angular
 
Building Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on AzureBuilding Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on Azure
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to Titanium
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive ui
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
 
jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013
 
Taking Micronaut out for a spin
Taking Micronaut out for a spinTaking Micronaut out for a spin
Taking Micronaut out for a spin
 
Gwt overview & getting started
Gwt overview & getting startedGwt overview & getting started
Gwt overview & getting started
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 

Kürzlich hochgeladen

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Kürzlich hochgeladen (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Tech Headline - JavaScript Performance

  • 1. JavaScript Performance You like it, it likes you! Rodrigo Castilho aka RODCAST Senior Front End Engineer @rodcast 3/29/2012 /1
  • 3. I'm your pain • Frontend is responsible for most of the performance Around 90% of the end-user response time is spent on the frontend. • What worked in the past, may not work today • Consumers are less tolerant than ever • Premature optimization is the root of all evil /3
  • 4. I'm your pain • Frontend is responsible for most of the performance • What worked in the past, may not work today Books demonstrate that there’s stuff that may not work in modern browsers because the browsers are in constant changes. • Consumers are less tolerant than ever • Premature optimization is the root of all evil /4
  • 5. I'm your pain • Frontend is responsible for most of the performance • What worked in the past, may not work today • Consumers are less tolerant than ever The consumers find bad performance unacceptable. They want websites to perform well during peak periods. • Premature optimization is the root of all evil /5
  • 6. I'm your pain • Frontend is responsible for most of the performance • What worked in the past, may not work today • Consumers are less tolerant than ever • Premature optimization is the root of all evil Avoiding poor quality coding can also improve performance, by avoiding obvious "slowdowns". /6
  • 9. Come on • Browser wars The function that runs lightning fast on one browser may perform sluggishly on another. • Use the latest version of jQuery • Plugins, plugins and more plugins • HTML and CSS (They are also very important) /9
  • 10. Come on • Browser wars • Use the latest version of jQuery The newest version is usually the best one. Also don’t forget to test your code after changing your jQuery core version. • Plugins, plugins and more plugins • HTML and CSS (They are also very important) / 10
  • 11. Come on • Browser wars • Use the latest version of jQuery • Plugins, plugins and more plugins Be careful with them, they can be evil. • HTML and CSS (They are also very important) / 11
  • 12. Come on • Browser wars • Use the latest version of jQuery • Plugins, plugins and more plugins • HTML and CSS (They are also very important) JavaScript doesn't work alone it also needs a set of other things for it to load faster. Validate your HTML and don't forget to test your pages. / 12
  • 13. Browser wars • V8 by Chrome • TraceMonkey by Firefox • SquirrelFish by Safari • JScript by Internet Explorer / 13
  • 14. Paranoid / 14
  • 15. Nothing seems to satisfy • 1 byte or 1ms is very precious. • Persistency is the key to a better user experience. • Let me give some examples with Expressions and Operators: • Chain, comparison, condition, special, bitwise, logical OR/AND… / 15
  • 21. Cache… all the time / 21
  • 22. Stewie Griffin I'm sure he was thinking of Internet Explorer. / 22
  • 23. The Evil That Men Do / 23
  • 24. Living on the razor's edge • Use HTML 5 The new HTML5 standard comes with a lighter DOM structure in mind. Lighter DOM structure means less elements to traverse for jQuery and better load performance. So, switch to it whenever it's possible. • Best Practices for a Faster Web App with HTML5 • Load content On-Demand (Lazy Load) • Use the correct method .bind() vs .live() vs .delegate() vs .on() • Change CSS classes not styles / 24
  • 25. Living on the razor's edge • Use HTML 5 • Best Practices for a Faster Web App with HTML5 Use web storage in place of cookies. Use CSS Transitions instead of JavaScript animation. Use client-side databases instead of server round-trips. • Load content On-Demand (Lazy Load) • Use the correct method .bind() vs .live() vs .delegate() vs .on() • Change CSS classes not styles / 25
  • 26. Living on the razor's edge • Use HTML 5 • Best Practices for a Faster Web App with HTML5 • Load content On-Demand (Lazy Load) An AJAX pattern is to load JavaScript dynamically or when the user runs a feature that requires your script. • Use the correct method .bind() vs .live() vs .delegate() vs .on() • Change CSS classes not styles / 26
  • 27. Living on the razor's edge • Use HTML 5 • Best Practices for a Faster Web App with HTML5 • Load content On-Demand (Lazy Load) • Use the correct method .bind() vs .live() vs .delegate() vs .on() With jQuery 1.7, new method that you should use is on() is the combination of bind, live and delegate method. • Change CSS classes not styles / 27
  • 28. Living on the razor's edge • Use HTML 5 • Best Practices for a Faster Web App with HTML5 • Load content On-Demand (Lazy Load) • Use the correct method .bind() vs .live() vs .delegate() vs .on() • Change CSS classes not styles You may have heard that changing CSS classes is more optimal than changing styles. / 28
  • 29. Beavis and Butt-Head Watching the presentation. / 29
  • 31. I'll take you to a place • Use jQuery only when it’s absolutely necessary Whenever possible you should not use it. Remember it’s sometimes more efficient to use regular JavaScript. • Use requestAnimationFrame instead of setInterval/setTimeout • Modernizr to give the user the experience expected • Cache Manifest (appCache) • Local Storage (cookies on steroids) / 31
  • 32. Native JavaScript is better (normally) / 32
  • 33. I'll take you to a place • Use jQuery only when it’s absolutely necessary • Use requestAnimationFrame instead of setInterval/setTimeout It throttles the animation for inactive tabs, so it won’t sap your mobile device’s battery if you leave it open in the background. • Modernizr to give the user the experience expected • Cache Manifest (appCache) • Local Storage (cookies on steroids) / 33
  • 34. I'll take you to a place • Use jQuery only when it’s absolutely necessary • Use requestAnimationFrame instead of setInterval/setTimeout • Modernizr to give the user the experience expected Modernizr is a JavaScript library that detects the features your browser can support, like HTML 5 and CSS3 .It let you manage what to do if the browser don't show something in the right way. • Cache Manifest (appCache) • Local Storage (cookies on steroids) / 34
  • 35. I'll take you to a place • Use jQuery only when it’s absolutely necessary • Use requestAnimationFrame instead of setInterval/setTimeout • Modernizr to give the user the experience expected • Cache Manifest (appCache) The application cache also persists between browser sessions. So, a web application that was previously used on the computer or device can continue to work offline - for example, when iOS has no network or is in airplane mode. • Local Storage (cookies on steroids) / 35
  • 37. I'll take you to a place • Use jQuery only when it’s absolutely necessary • Use requestAnimationFrame instead of setInterval/setTimeout • Modernizr to give the user the experience expected • Cache Manifest (appCache) • Local Storage (cookies on steroids) Local Storage is a dead simple API for storing information on the client side. / 37
  • 39. Stewie Griffin Again, again I love repetition... Stewie begins taking steroids after he is beat up by a baby girl. / 39
  • 41. Hold your breath • Without bugs You will agree that performance is very important but "bug free" is the most important thing of all. Then you should fix the bugs and not forget the performance. • Create unit tests • Never forget • Use the powerful tools in your favor • JSPerf is your partner / 41
  • 42. Hold your breath • Without bugs • Create unit tests The best way to test a JavaScript code is the human way but you can still use some automated tools. • Never forget • Use the powerful tools in your favor • JSPerf is your partner / 42
  • 43. Hold your breath • Without bugs • Create unit tests • Never forget Make JavaScript and CSS External Minify JavaScript and CSS Make Ajax Cacheable Gzip Components Put Stylesheets at Top Put Scripts at Bottom Optimize Images and create CSS Sprites • Use the powerful tools in your favor • JSPerf is your partner / 43
  • 44. Hold your breath • Without bugs • Create unit tests • Never forget • Use the powerful tools in your favor JSLint/JSHint, JSPerf, JSMeter, FireQuery, JS Console, FireUnit, CSS Lint, Web Developer, Firebug, JSView, Fiddler, HTTPFox, Live HTTP headers, YUI Compressor, Google Closure, Microsoft Ajax Minifier, YSlow, Google Page Speed, MySpace Performance Tracker, IBM Page Detailer, HTTPD Watch, Web Page Test, Speed Tracer, Dyna Tracer, ZocDoc, ShowSlow, Smush.it between other tools. • JSPerf is your partner / 44
  • 45. Hold your breath • Without bugs • Create unit tests • Never forget • Use the powerful tools in your favor • JSPerf is your partner A performance playground for JavaScript developers that allows to write your tests. / 45
  • 46. Homer Simpson WOOHOO!!! I hope I haven't forgotten anything. / 46
  • 47. Musics mentioned • Sad But True – Metallica • Know Your Enemy - Rage Against The Machine • Paranoid - Black Sabbath • The Evil That Men Do - Iron Maiden • Roots Bloody Roots - Sepultura • Before I Forget - Slipknot / 47