10. Excessive use of string manipulations
Manipulations of the DOM
DOM object lookups using CSS Selectors
Problematic 3rd party javascript libraries
Too many or long running XHR calls
What makes Slow Down?
11. Use unique ID when possible
Specify a Tag name if you have to use
the Class Name
$(“ .active-panel”) -> $(“ div.active-panel”)
Specify a parent context
$(“ div.active-panel”) -> $(“div.active-panel”, $(“#wrap”))
Cache Lookup Results
for(var i=0;i<10;i++) $(“div.active-panel”, $
(“#wrap”)).doSomething();
<-
var wrap = $(“#wrap”), actives = $(“div.active-panel”, wrap);
for(var i=0;i<10;i++) actives.doSomething();
Reduce the DOM Size
Slow CSS Selector
13. Changing the class
name – especially on
the body tag causes
the browser to re-
evaluate all elements
on the page.
Manipulating the DOM
14. Reducing Codes and Files
make sure you understand how frameworks
work and optimize it
Focus on long running JavaScript blocks and
long running methods
Recommendations and Savings
15. less than 2 javascript files
less than 20ms execution time per
<script>
connection limits
Browser less than 5 XHR Calls at the same time
HTTP 1.1
IE 6,7 2
IE 8 6
Firefox 3+ 6
Chrome 4+ 6
iPhone 4 4
Opera 10.5+ 8
Rank Calculations