SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Javascript Performance:
Speeding up your Ajax apps
Who am I?
• Front-end Developer at Freewebs.com
 • Freewebs is:
   • web publishing platform
   • 17 million unique visitors a month
   • top 300 site according to alexa
   • Hiring Javascript Developers!
Areas of Focus

• Javascript Optimization
• DOM Interactions
• User Experience
• Application Delivery
Why Javascript
Optimizing is Important

• Slow Apps loose users
 • Example: Yahoo! Mail beta vs Gmail
Why Javascript
Optimizing is Important
Javascript Optimization
“We should forget about smallthe
 efficiencies, say about 97% of
  time: premature optimization is
  the root of all evil. Yet we should
  not pass up our opportunities in
                  ”
  that critical 3%.
     - Donald Knuth
Javascript Optimization

•   Profile Your Code!

    •   Use Firebug

•   80/20 Rule

•   Working within the
    limitations
Profiling Code
var start = new Date().getTime();

// Execute code you want to profile
// Compute Pi

var end = new Date().getTime();
alert('Function took: '+ (end-start) + ' ms');
Firebug for Profiling
• Helps you know what to optimize
• Use Firebug - http://www.getfirebug.com/
80/20 Rule
• Think before you optimize
• No compulsive optimizing
• Life is too short to optimize in the wrong
  spot
Working within the
      Limitations
• Algorithms Still Matter
   • (Just usually not the ones you write)
• Harness the underlying algorithms
  (browsers internal implementations of js)
• Not all browsers implement things the same
  way
Optimizing Javascript vs
  Other Languages

• Focus on use experience not resources use
• Few documents on optimizing
• Not the same in all browsers
• High level optimizing
Be Aware of Poor
        Documentation
•   Using var is optional, but you need to use it if you have
    a variable that has been declared global and you want
    to re-declare it as a local variable inside a function.
    * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/
    javascript-tutorial.html

•   The word var is optional (but it’s good style to use it)
    * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21-
    javascript.ppt

•   The "var" is optional but should be used for good style
    * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
Be Aware of Poor
        Documentation
•   Using var is optional, but you need to use it if you have
    a variable that has been declared global and you want
    to re-declare it as a local variable inside a function.
    * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/
    javascript-tutorial.html

•   The word var is optional (but it’s good style to use it)
    * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21-
    javascript.ppt

•   The "var" is optional but should be used for good style
    * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
Be Aware of Poor
        Documentation
•   Using var is optional, but you need to use it if you have
    a variable that has been declared global and you want
    to re-declare it as a local variable inside a function.
    * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/
    javascript-tutorial.html

•   The word var is optional (but it’s good style to use it)
    * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21-
    javascript.ppt

•   The "var" is optional but should be used for good style
    * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
Be Aware of Poor
        Documentation
•   Using var is optional, but you need to use it if you have
    a variable that has been declared global and you want
    to re-declare it as a local variable inside a function.
    * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/
    javascript-tutorial.html

•   The word var is optional (but it’s good style to use it)
    * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21-
    javascript.ppt

•   The "var" is optional but should be used for good style
    * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
Be Aware of Poor
        Documentation
•   Using var is optional, but you need to use it if you have
    a variable that has been declared global and you want
    to re-declare it as a local variable inside a function.
    * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/
    javascript-tutorial.html

•   The word var is optional (but it’s good style to use it)
    * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21-
    javascript.ppt

•   The "var" is optional but should be used for good style
    * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html

       See me after class!
Things to Avoid in
Performance Critical Code
• Global Variables      - use var
•   try-catch-finally   statements
•   with   statement - should always be avoided
•   eval

•   x = new Boolean, Number, String...

     • Use literals instead,   x = 5, ‘blue’, false
Literals Example
var b = false;
b.num = 5;
alert(b.num); // alerts undefined

var b = new Boolean(false);
b.num = 5;
alert(b.num); // alerts 5
Things to do:
               Reference Reuse
document.getElementById('report').style.padding = '10px';
document.getElementById('report').style.margin = '5px';
document.getElementById('report').style.border = '1px black';



// Can be shortened to: (saves 11 lookups)
var reportStyle = document.getElementById('report').style;
reportStyle.padding = '10px';
reportStyle.margin = '5px';
reportStyle.border = '1px solid black';
DOM Interactions




Look at why people who get IE with a new machine switch to Navigator
and what is being addressed in IE 4.0 to make that difficult.
  - Microsoft executive Jonathan Roberts, e-mail, March 28, 1997
DOM Interactions
• Minimize Reflows
     •   Set display: none; before multiple DOM updates

     •   appendChild from the inside out

• Mitigate Reflows
 •   Prevent reflows from cascading

 •   Absolutely position if necessary

• Manage Reflows
 •   Consider faking more complex DOM structures with
     simpler dynamic structures (onScroll)
DOM Objects, Closures, and
          Memory Leaks
• Mostly affects IE 6 and below
 • Stems from Flaw in IE garbage collector
• Objects in JS are only reclaimed when
   nothing points to them
  • Cycles can not be reclaimed
• Can be caused by event handlers
User Experience
User Experience
• Browsers are Single Threaded
 • setTimeout is your friend
 • Interactivity beats Response Time
 • Keep users informed
 • Programmers need to be part psychologist
Application Delivery
Application Delivery

• Load Time Factors:
 • File Size
 • Number of Files
 • Caching
Load Time Analysis
.js Delivery Suggestions

• Gzip
• Concat - Lower total requests
• Minify - jsmin
    • http://www.crockford.com/javascript/jsmin.html
•   Set Expiration Date
      • Helps with caching
Resources
• Slides at:
 • http://ryanstout.webs.com/
• Opera:
  •   http://dev.opera.com/articles/view/efficient-javascript/

• IE:
  •   http://blogs.msdn.com/ie/archive/2006/08/28/728654.aspx
EOF


• Questions?/Comments
• Freewebs.com - We’re Hiring!
• Thanks!

Contenu connexe

Tendances

Web development basics (Part-4)
Web development basics (Part-4)Web development basics (Part-4)
Web development basics (Part-4)Rajat Pratap Singh
 
STP201 Efficiency at Scale - AWS re: Invent 2012
STP201 Efficiency at Scale - AWS re: Invent 2012STP201 Efficiency at Scale - AWS re: Invent 2012
STP201 Efficiency at Scale - AWS re: Invent 2012Amazon Web Services
 
Web development basics (Part-7)
Web development basics (Part-7)Web development basics (Part-7)
Web development basics (Part-7)Rajat Pratap Singh
 
A Performant Scheme Interpreter in asm.js
A Performant Scheme Interpreter in asm.jsA Performant Scheme Interpreter in asm.js
A Performant Scheme Interpreter in asm.jsnoahves
 
Web development basics (Part-6)
Web development basics (Part-6)Web development basics (Part-6)
Web development basics (Part-6)Rajat Pratap Singh
 
Why does my jenkins freeze sometimes and what can I do about it?
Why does my jenkins freeze sometimes and what can I do about it?Why does my jenkins freeze sometimes and what can I do about it?
Why does my jenkins freeze sometimes and what can I do about it?Tidhar Klein Orbach
 
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016Bart Read
 

Tendances (12)

Web development basics (Part-4)
Web development basics (Part-4)Web development basics (Part-4)
Web development basics (Part-4)
 
Scala goods bads
Scala goods badsScala goods bads
Scala goods bads
 
STP201 Efficiency at Scale - AWS re: Invent 2012
STP201 Efficiency at Scale - AWS re: Invent 2012STP201 Efficiency at Scale - AWS re: Invent 2012
STP201 Efficiency at Scale - AWS re: Invent 2012
 
Web development basics (Part-7)
Web development basics (Part-7)Web development basics (Part-7)
Web development basics (Part-7)
 
FireBug And FirePHP
FireBug And FirePHPFireBug And FirePHP
FireBug And FirePHP
 
A Performant Scheme Interpreter in asm.js
A Performant Scheme Interpreter in asm.jsA Performant Scheme Interpreter in asm.js
A Performant Scheme Interpreter in asm.js
 
Web development basics (Part-6)
Web development basics (Part-6)Web development basics (Part-6)
Web development basics (Part-6)
 
Low-Maintenance Perl
Low-Maintenance PerlLow-Maintenance Perl
Low-Maintenance Perl
 
Why does my jenkins freeze sometimes and what can I do about it?
Why does my jenkins freeze sometimes and what can I do about it?Why does my jenkins freeze sometimes and what can I do about it?
Why does my jenkins freeze sometimes and what can I do about it?
 
Rubyhosting
RubyhostingRubyhosting
Rubyhosting
 
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016
 
CSS 201
CSS 201CSS 201
CSS 201
 

En vedette

εξ αποστάσεως εκπαίδευση τυπογραφική τέχνη
εξ αποστάσεως εκπαίδευση  τυπογραφική τέχνηεξ αποστάσεως εκπαίδευση  τυπογραφική τέχνη
εξ αποστάσεως εκπαίδευση τυπογραφική τέχνηGeorge Exarchopoulos
 
εξ αποστάσεως εκπαίδευση υποδομή στη γραφιστική
εξ αποστάσεως εκπαίδευση υποδομή στη γραφιστικήεξ αποστάσεως εκπαίδευση υποδομή στη γραφιστική
εξ αποστάσεως εκπαίδευση υποδομή στη γραφιστικήGeorge Exarchopoulos
 
after ice rain in China
after ice rain in Chinaafter ice rain in China
after ice rain in ChinaShiva
 
Hadoop 0.23 m_rv2_introduction
Hadoop 0.23 m_rv2_introductionHadoop 0.23 m_rv2_introduction
Hadoop 0.23 m_rv2_introductionJinGui LI
 
WesołYch śWiąT
WesołYch śWiąTWesołYch śWiąT
WesołYch śWiąTsobiana
 
D I A B E T E S A N D B H R A M A R I D R S H R I N I W A S K A S H A L ...
D I A B E T E S  A N D  B H R A M A R I  D R  S H R I N I W A S  K A S H A L ...D I A B E T E S  A N D  B H R A M A R I  D R  S H R I N I W A S  K A S H A L ...
D I A B E T E S A N D B H R A M A R I D R S H R I N I W A S K A S H A L ...banothkishan
 
Seminario Mexico Italia
Seminario Mexico ItaliaSeminario Mexico Italia
Seminario Mexico Italiacusimano
 
εξ αποστάσεως εκπαίδευση Rhino gold
εξ αποστάσεως  εκπαίδευση Rhino goldεξ αποστάσεως  εκπαίδευση Rhino gold
εξ αποστάσεως εκπαίδευση Rhino goldGeorge Exarchopoulos
 
02-23-25 Audio slideshow lecture
02-23-25 Audio slideshow lecture02-23-25 Audio slideshow lecture
02-23-25 Audio slideshow lectureSung Woo Yoo
 
Dryad Paper Review and System Analysis
Dryad Paper Review and System AnalysisDryad Paper Review and System Analysis
Dryad Paper Review and System AnalysisJinGui LI
 
3. Analisi del Target Profit e del Margine di Sicurezza
3. Analisi del Target Profit e del Margine di Sicurezza3. Analisi del Target Profit e del Margine di Sicurezza
3. Analisi del Target Profit e del Margine di SicurezzaManager.it
 
[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAti
[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAti[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAti
[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAtiConfesercenti Ravenna
 
Vray 3D max Εξ Αποστάσεως
Vray 3D max Εξ ΑποστάσεωςVray 3D max Εξ Αποστάσεως
Vray 3D max Εξ ΑποστάσεωςGeorge Exarchopoulos
 
Web Analytics - WHR 2012 - Guida pratica Google Analytics
Web Analytics - WHR 2012 - Guida pratica Google AnalyticsWeb Analytics - WHR 2012 - Guida pratica Google Analytics
Web Analytics - WHR 2012 - Guida pratica Google AnalyticsEnrico Ferretti
 
Google Analytics- Cos'è e come funziona?
Google Analytics- Cos'è e come funziona?Google Analytics- Cos'è e come funziona?
Google Analytics- Cos'è e come funziona?Giulia Forghieri
 
ECDL Level 2 - Introduction for students
ECDL Level 2 - Introduction for studentsECDL Level 2 - Introduction for students
ECDL Level 2 - Introduction for studentsDavid Drake
 

En vedette (17)

εξ αποστάσεως εκπαίδευση τυπογραφική τέχνη
εξ αποστάσεως εκπαίδευση  τυπογραφική τέχνηεξ αποστάσεως εκπαίδευση  τυπογραφική τέχνη
εξ αποστάσεως εκπαίδευση τυπογραφική τέχνη
 
εξ αποστάσεως εκπαίδευση υποδομή στη γραφιστική
εξ αποστάσεως εκπαίδευση υποδομή στη γραφιστικήεξ αποστάσεως εκπαίδευση υποδομή στη γραφιστική
εξ αποστάσεως εκπαίδευση υποδομή στη γραφιστική
 
after ice rain in China
after ice rain in Chinaafter ice rain in China
after ice rain in China
 
Hadoop 0.23 m_rv2_introduction
Hadoop 0.23 m_rv2_introductionHadoop 0.23 m_rv2_introduction
Hadoop 0.23 m_rv2_introduction
 
WesołYch śWiąT
WesołYch śWiąTWesołYch śWiąT
WesołYch śWiąT
 
D I A B E T E S A N D B H R A M A R I D R S H R I N I W A S K A S H A L ...
D I A B E T E S  A N D  B H R A M A R I  D R  S H R I N I W A S  K A S H A L ...D I A B E T E S  A N D  B H R A M A R I  D R  S H R I N I W A S  K A S H A L ...
D I A B E T E S A N D B H R A M A R I D R S H R I N I W A S K A S H A L ...
 
Seminario Mexico Italia
Seminario Mexico ItaliaSeminario Mexico Italia
Seminario Mexico Italia
 
εξ αποστάσεως εκπαίδευση Rhino gold
εξ αποστάσεως  εκπαίδευση Rhino goldεξ αποστάσεως  εκπαίδευση Rhino gold
εξ αποστάσεως εκπαίδευση Rhino gold
 
02-23-25 Audio slideshow lecture
02-23-25 Audio slideshow lecture02-23-25 Audio slideshow lecture
02-23-25 Audio slideshow lecture
 
Dryad Paper Review and System Analysis
Dryad Paper Review and System AnalysisDryad Paper Review and System Analysis
Dryad Paper Review and System Analysis
 
Media representation key terms
Media representation key termsMedia representation key terms
Media representation key terms
 
3. Analisi del Target Profit e del Margine di Sicurezza
3. Analisi del Target Profit e del Margine di Sicurezza3. Analisi del Target Profit e del Margine di Sicurezza
3. Analisi del Target Profit e del Margine di Sicurezza
 
[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAti
[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAti[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAti
[Giornate dell'E-Commerce 2015] Robi Veltroni e i ristoranti prenOTAti
 
Vray 3D max Εξ Αποστάσεως
Vray 3D max Εξ ΑποστάσεωςVray 3D max Εξ Αποστάσεως
Vray 3D max Εξ Αποστάσεως
 
Web Analytics - WHR 2012 - Guida pratica Google Analytics
Web Analytics - WHR 2012 - Guida pratica Google AnalyticsWeb Analytics - WHR 2012 - Guida pratica Google Analytics
Web Analytics - WHR 2012 - Guida pratica Google Analytics
 
Google Analytics- Cos'è e come funziona?
Google Analytics- Cos'è e come funziona?Google Analytics- Cos'è e come funziona?
Google Analytics- Cos'è e come funziona?
 
ECDL Level 2 - Introduction for students
ECDL Level 2 - Introduction for studentsECDL Level 2 - Introduction for students
ECDL Level 2 - Introduction for students
 

Similaire à Ajaxworld07

Tech Headline - JavaScript Performance
Tech Headline - JavaScript PerformanceTech Headline - JavaScript Performance
Tech Headline - JavaScript PerformanceRodrigo Castilho
 
WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxTusharTikia
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015Christian Heilmann
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterpriseTaylor Lovett
 
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex BlomBrowser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex BlomAlex Blom
 
BITM3730Week6.pptx
BITM3730Week6.pptxBITM3730Week6.pptx
BITM3730Week6.pptxMattMarino13
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
WT Module-3.pptx
WT Module-3.pptxWT Module-3.pptx
WT Module-3.pptxRamyaH11
 
DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtNick Santamaria
 
lessons from managing a pulsar cluster
 lessons from managing a pulsar cluster lessons from managing a pulsar cluster
lessons from managing a pulsar clusterShivji Kumar Jha
 
JavaScript Comprehensive Overview
JavaScript Comprehensive OverviewJavaScript Comprehensive Overview
JavaScript Comprehensive OverviewMohamed Loey
 
JavaScript : A trending scripting language
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting languageAbhayDhupar
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingFITC
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactTyler Peterson
 

Similaire à Ajaxworld07 (20)

Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
Tech Headline - JavaScript Performance
Tech Headline - JavaScript PerformanceTech Headline - JavaScript Performance
Tech Headline - JavaScript Performance
 
WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptx
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex BlomBrowser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
 
BITM3730Week6.pptx
BITM3730Week6.pptxBITM3730Week6.pptx
BITM3730Week6.pptx
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
JS Essence
JS EssenceJS Essence
JS Essence
 
WT Module-3.pptx
WT Module-3.pptxWT Module-3.pptx
WT Module-3.pptx
 
Java script core
Java script coreJava script core
Java script core
 
DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an Afterthought
 
lessons from managing a pulsar cluster
 lessons from managing a pulsar cluster lessons from managing a pulsar cluster
lessons from managing a pulsar cluster
 
JavaScript Comprehensive Overview
JavaScript Comprehensive OverviewJavaScript Comprehensive Overview
JavaScript Comprehensive Overview
 
Welcome to React.pptx
Welcome to React.pptxWelcome to React.pptx
Welcome to React.pptx
 
JavaScript : A trending scripting language
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting language
 
Web Technology Part 2
Web Technology Part 2Web Technology Part 2
Web Technology Part 2
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and React
 

Plus de tutorialsruby

<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>tutorialsruby
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />tutorialsruby
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

Plus de tutorialsruby (20)

<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Dernier

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Dernier (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Ajaxworld07

  • 2. Who am I? • Front-end Developer at Freewebs.com • Freewebs is: • web publishing platform • 17 million unique visitors a month • top 300 site according to alexa • Hiring Javascript Developers!
  • 3. Areas of Focus • Javascript Optimization • DOM Interactions • User Experience • Application Delivery
  • 4. Why Javascript Optimizing is Important • Slow Apps loose users • Example: Yahoo! Mail beta vs Gmail
  • 6. Javascript Optimization “We should forget about smallthe efficiencies, say about 97% of time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in ” that critical 3%. - Donald Knuth
  • 7. Javascript Optimization • Profile Your Code! • Use Firebug • 80/20 Rule • Working within the limitations
  • 8. Profiling Code var start = new Date().getTime(); // Execute code you want to profile // Compute Pi var end = new Date().getTime(); alert('Function took: '+ (end-start) + ' ms');
  • 9. Firebug for Profiling • Helps you know what to optimize • Use Firebug - http://www.getfirebug.com/
  • 10. 80/20 Rule • Think before you optimize • No compulsive optimizing • Life is too short to optimize in the wrong spot
  • 11. Working within the Limitations • Algorithms Still Matter • (Just usually not the ones you write) • Harness the underlying algorithms (browsers internal implementations of js) • Not all browsers implement things the same way
  • 12. Optimizing Javascript vs Other Languages • Focus on use experience not resources use • Few documents on optimizing • Not the same in all browsers • High level optimizing
  • 13. Be Aware of Poor Documentation • Using var is optional, but you need to use it if you have a variable that has been declared global and you want to re-declare it as a local variable inside a function. * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/ javascript-tutorial.html • The word var is optional (but it’s good style to use it) * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21- javascript.ppt • The "var" is optional but should be used for good style * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
  • 14. Be Aware of Poor Documentation • Using var is optional, but you need to use it if you have a variable that has been declared global and you want to re-declare it as a local variable inside a function. * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/ javascript-tutorial.html • The word var is optional (but it’s good style to use it) * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21- javascript.ppt • The "var" is optional but should be used for good style * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
  • 15. Be Aware of Poor Documentation • Using var is optional, but you need to use it if you have a variable that has been declared global and you want to re-declare it as a local variable inside a function. * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/ javascript-tutorial.html • The word var is optional (but it’s good style to use it) * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21- javascript.ppt • The "var" is optional but should be used for good style * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
  • 16. Be Aware of Poor Documentation • Using var is optional, but you need to use it if you have a variable that has been declared global and you want to re-declare it as a local variable inside a function. * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/ javascript-tutorial.html • The word var is optional (but it’s good style to use it) * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21- javascript.ppt • The "var" is optional but should be used for good style * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html
  • 17. Be Aware of Poor Documentation • Using var is optional, but you need to use it if you have a variable that has been declared global and you want to re-declare it as a local variable inside a function. * http://www.cs.brown.edu/courses/bridge/1998/res/javascript/ javascript-tutorial.html • The word var is optional (but it’s good style to use it) * http://www.cis.upenn.edu/~matuszek/cit597-2003/Lectures/21- javascript.ppt • The "var" is optional but should be used for good style * http://www.acm.uiuc.edu/webmonkeys/javascript/variables.html See me after class!
  • 18. Things to Avoid in Performance Critical Code • Global Variables - use var • try-catch-finally statements • with statement - should always be avoided • eval • x = new Boolean, Number, String... • Use literals instead, x = 5, ‘blue’, false
  • 19. Literals Example var b = false; b.num = 5; alert(b.num); // alerts undefined var b = new Boolean(false); b.num = 5; alert(b.num); // alerts 5
  • 20. Things to do: Reference Reuse document.getElementById('report').style.padding = '10px'; document.getElementById('report').style.margin = '5px'; document.getElementById('report').style.border = '1px black'; // Can be shortened to: (saves 11 lookups) var reportStyle = document.getElementById('report').style; reportStyle.padding = '10px'; reportStyle.margin = '5px'; reportStyle.border = '1px solid black';
  • 21. DOM Interactions Look at why people who get IE with a new machine switch to Navigator and what is being addressed in IE 4.0 to make that difficult. - Microsoft executive Jonathan Roberts, e-mail, March 28, 1997
  • 22. DOM Interactions • Minimize Reflows • Set display: none; before multiple DOM updates • appendChild from the inside out • Mitigate Reflows • Prevent reflows from cascading • Absolutely position if necessary • Manage Reflows • Consider faking more complex DOM structures with simpler dynamic structures (onScroll)
  • 23. DOM Objects, Closures, and Memory Leaks • Mostly affects IE 6 and below • Stems from Flaw in IE garbage collector • Objects in JS are only reclaimed when nothing points to them • Cycles can not be reclaimed • Can be caused by event handlers
  • 25. User Experience • Browsers are Single Threaded • setTimeout is your friend • Interactivity beats Response Time • Keep users informed • Programmers need to be part psychologist
  • 27. Application Delivery • Load Time Factors: • File Size • Number of Files • Caching
  • 29. .js Delivery Suggestions • Gzip • Concat - Lower total requests • Minify - jsmin • http://www.crockford.com/javascript/jsmin.html • Set Expiration Date • Helps with caching
  • 30. Resources • Slides at: • http://ryanstout.webs.com/ • Opera: • http://dev.opera.com/articles/view/efficient-javascript/ • IE: • http://blogs.msdn.com/ie/archive/2006/08/28/728654.aspx
  • 31. EOF • Questions?/Comments • Freewebs.com - We’re Hiring! • Thanks!