• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
5 Quick JavaScript Performance Improvement Tips
 

5 Quick JavaScript Performance Improvement Tips

on

  • 3,204 views

JavaScript is arguably the most important language in the world. It comes included in nearly every desktop and mobile browser. It powers the client-side of apps like Facebook and GMail. It is the ...

JavaScript is arguably the most important language in the world. It comes included in nearly every desktop and mobile browser. It powers the client-side of apps like Facebook and GMail. It is the language of choice for mobile development environments like Apccelerator's Titanium and Apache's Cordova (aka Adobe's PhoneGap). It is even on the server now in Node.js. Yet when programmer's run into performance issue with JavaScript their first inclination is to blame its interpreted nature, not realizing that simple changes in the structure of their code can result in sometimes significant improvements in performance. In this session I will show five quick changes you can make to your JavaScript code to improve its performance and explain why they work.

Statistics

Views

Total Views
3,204
Views on SlideShare
2,381
Embed Views
823

Actions

Likes
1
Downloads
17
Comments
0

40 Embeds 823

http://therockncoder.blogspot.com 377
http://techachance.com 67
http://therockncoder.blogspot.co.uk 59
http://therockncoder.blogspot.in 45
http://therockncoder.blogspot.de 32
http://therockncoder.blogspot.ca 30
http://therockncoder.blogspot.com.es 29
http://therockncoder.blogspot.com.au 28
http://therockncoder.blogspot.fr 16
http://t.co 14
http://therockncoder.blogspot.it 12
http://therockncoder.blogspot.nl 11
http://therockncoder.blogspot.dk 11
http://therockncoder.blogspot.com.br 10
http://therockncoder.blogspot.ru 9
http://therockncoder.blogspot.se 9
http://therockncoder.blogspot.cz 8
http://therockncoder.blogspot.be 5
http://therockncoder.blogspot.mx 5
http://therockncoder.blogspot.fi 4
http://therockncoder.blogspot.hu 4
http://therockncoder.blogspot.co.at 4
http://therockncoder.blogspot.no 4
http://therockncoder.blogspot.ie 4
http://therockncoder.blogspot.ch 4
http://therockncoder.blogspot.jp 3
http://therockncoder.blogspot.tw 2
http://therockncoder.blogspot.pt 2
http://therockncoder.blogspot.hk 2
http://therockncoder.blogspot.sg 2
http://therockncoder.blogspot.co.il 2
http://yeung13.zahooga.com 1
https://www.rebelmouse.com 1
http://therockncoder.blogspot.sk 1
http://therockncoder.blogspot.com.ar 1
http://www.therockncoder.blogspot.co.uk 1
http://therockncoder.blogspot.kr 1
http://therockncoder.blogspot.gr 1
http://translate.googleusercontent.com 1
http://therockncoder.blogspot.co.nz 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    5 Quick JavaScript Performance Improvement Tips 5 Quick JavaScript Performance Improvement Tips Presentation Transcript

    • 5 Quick JavaScript Performance Improvement Tips 30 January 2014
    • Twitter handle: @therockncoder
    • The Rock n Coder • http://therockncoder.blogspot.com • http://www.youtube.com/user/rockncoder • https://github.com/Rockncoder • http://www.slideshare.net/rockncoder
    • Our Agenda • Why Performance Matters • 5 Performance Tips • Resources • Summary
    • Why Performance Matters?
    • Why Performance Matters? • 47% of consumers expect a 2 second page load • 40% abandon a page that takes 3 seconds or more to load • A 1 second delay in page response can result in a 7% reduction in conversions
    • If an e-commerce site is making $100,000 a day in sales, a 1 second page delay could potentially cost you $2.5 million in lost sales every year
    • We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.Yet we should not pass up our opportunities in that critical 3%. D. Knuth
    • 5 Performance Tips
    • Tip #5 Use as few files as possible
    • Use as few files as possible • Browser can load multiple files at a time • But only one JS file at a time • Concatenate multiple JS file into one • Compress JS files • Prefer JS at the bottom of the HTML file
    • Tip #4 Prefer local variables
    • Prefer local variables • Variables in scope found quicker • JS search local scope, then global • with creates a new scope level ahead of local • closures also create new scope level
    • Var Scoping Demo
    • Prefer local variables • Property chains similar to var scoping • Objects closer in the chain found quicker
    • Property Chain Demo
    • Tip #3 Reduce the work done in loops
    • Reduce the work done in loops • No real speed difference between: for, while and do_while • Avoid for_in • (Watch library based for_each)
    • Tip #2 Watch your plugins
    • Watch your plugins • Know what your plugins do • Be sure to evaluate different plugins • Example jQuery.js or Zepto.js
    • jQuery Demo
    • Tip #1 Avoid the DOM
    • Avoid the DOM • The DOM is REALLY Slow • Avoid accessing it when possible • Do work offline then update DOM
    • DOM Access Demo
    • Resources
    • Resources • Microsoft Ajax Minifier
 http://ajaxmin.codeplex.com/ • Google Closure Tools
 https://developers.google.com/closure/ • Yahoo YSlow
 http://developer.yahoo.com/yslow/
    • Books • High Performance JavaScript
 Nicholas C. Zakas • JavaScript Ninja
 John Resig & Bear Bibeaults • JavaScript: The Good Parts
 Douglas Crockford

    • Summary
    • Summary • Avoid the DOM • Watch your plugins • Reduce the work done in loops • Prefer local variables • Use as few files as possible
    • The Rock n Coder • http://therockncoder.blogspot.com • http://www.youtube.com/user/rockncoder • https://github.com/Rockncoder • http://www.slideshare.net/rockncoder