SlideShare ist ein Scribd-Unternehmen logo
1 von 29
JavaScript
Performance Tricks
   Grgur Grisogono - @ggrgur
Evaluation

eval(foo)
   vs
(new Function(foo))()
Evaluation
                       eval(foo)
                       (new Function(foo))()
6,000
             5,256


4,500


3,000


1,500                       1,081


        97            79              110         160   42         47
   0
        Chrome 21     Firefox 12            IE8              IE7
String Concatenation
                                                   foo = foo + bar
                                                   foo += bar
                                                   [].join(’’)

20,000,000               18,817,419



15,000,000


             9,940,504
10,000,000

                                6,348,293

 5,000,000                                  4,503,838              4,191,713

                                                                                     1,359,961
                                                                               825,543
                                                    435,988   347,348                          443,218
        0
                Chrome 21             Firefox 12          IE9           Safari 5     iOS Safari 5.1.1
String Concatenation
                                      foo = foo + bar
                                      foo += bar
                                      [].join(’’)
                                      foo.concat(bar)
                                                             93,236,430




      56,781,122




  18,817,419             21,484,919


                     4,503,838                                                 5,878,675
                                            1,320,424
                                         347,348         1,493,283          443,218

Chrome 21          Firefox 12            IE9            Safari 5      iOS Safari 5.1.1
String Concatenation
                                            foo = foo + bar
                                            foo += bar
                                            [].join(’’)
                                            foo.concat(bar)
                                                                         93,236,430




            56,781,122




                               21,484,919

9,940,504
                  6,348,293                                  4,191,713                     5,878,675
                                      435,988         1,320,424                1,359,961

    Chrome 21            Firefox 12             IE9                Safari 5       iOS Safari 5.1.1
String Concatenation
String Concatenation
Loops
Loops
                      for loop         while loop

900,000


675,000


450,000


225,000


     0
          Chrome 21              Firefox 12         IE9
Nested Object
 Properties
Nested Object
               Properties
                         deep          shallow

60,000,000


45,000,000


30,000,000


15,000,000


        0
             Chrome 21          Firefox 12       Desktop Safari 5
Reuse Array Refs
                                         foo = [1]
                                         foo.length = 0; foo.push(1)


300,000,000


              221,911,826
225,000,000


150,000,000


 75,000,000

                            10,688,860        10,964,912 18,867,925
                                                                       1,311,286   1,670,314
         0
                   Chrome 21                       Firefox 12                  IE9
Reuse Array Refs
                           foo = [1]
                           foo.length = 0; foo.push(1)


                                          18,867,925                 1,670,314


                                                         1,311,286
221,911,826

                             10,964,912




              10,688,860

    Chrome 21                    Firefox 12                      IE9
Reuse Array Refs
                          foo = [1]
                          foo.length = 0; foo.push(1)


             49,678,120

                                                         2,493,830




                                             1,030,567
14,644,518




 Desktop Safari 5                       Mobile Safari iPhone 4S 5.1.1
Overusing Closures
Minimize Number of
      Events
Minimize Number of
      Events
Timers
0
                                                10 ms timer #1 started
     Time in ms




                                                Screen resized
10                 Main JS code execution
                                                Timer #1 has expired

20

                  Screen resize event handler   10 ms timer #2 started

30
                       Timer #1 handler         Timer #2 has expired


40                     Timer #2 handler         10ms timer #3 started


50

                       Timer #3 handler
Adding Elements To
      DOM
Adding Elements To
      DOM
Adding Elements To
      DOM
Adding Elements To
      DOM
Adding Elements To
               DOM
           innerHTML                  DOM methods/replaceChild
           DOM/cloneNode              DocumentFragment
15,000


11,250


 7,500


 3,750


    0
         Chrome 21 Firefox 12   IE8       Safari    Opera   Mobile Safari
Updating CSS Styles
Updating CSS Styles
                    style            cssText

70,000


52,500


35,000                                                     69,621
                            62,893
           58,388

                                     40,058
17,500


    0
                Chrome 21                     Firefox 12
Selectors
Selectors
      table                                #menu              .first
      li.first                              #menu .first        #menu > li.first
      div#div1 table #menu li.first

1,500,000


1,125,000


 750,000


 375,000


       0
             Chrome 21       Desktop Safari 5    Firefox 12          IE9
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Coq Tutorial
Coq TutorialCoq Tutorial
Coq Tutorialtmiya
 
Becoming a better developer with EXPLAIN
Becoming a better developer with EXPLAINBecoming a better developer with EXPLAIN
Becoming a better developer with EXPLAINLouise Grandjonc
 
Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesIbrar Ahmed
 
A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009Jordan Baker
 
Clustering com numpy e cython
Clustering com numpy e cythonClustering com numpy e cython
Clustering com numpy e cythonAnderson Dantas
 

Was ist angesagt? (6)

Coq Tutorial
Coq TutorialCoq Tutorial
Coq Tutorial
 
Becoming a better developer with EXPLAIN
Becoming a better developer with EXPLAINBecoming a better developer with EXPLAIN
Becoming a better developer with EXPLAIN
 
League of Graphs
League of GraphsLeague of Graphs
League of Graphs
 
Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL Indexes
 
A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009
 
Clustering com numpy e cython
Clustering com numpy e cythonClustering com numpy e cython
Clustering com numpy e cython
 

Andere mochten auch

The China Analyst March 2011
The China Analyst   March 2011The China Analyst   March 2011
The China Analyst March 2011Barryvanwyk
 
tori . michelle . keenan . austun . kevin
tori . michelle . keenan . austun . kevintori . michelle . keenan . austun . kevin
tori . michelle . keenan . austun . kevinlovelytori
 
SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch Patrick Sheridan
 
Eenpondverenbloeifactorharrietkollen keywork-1
Eenpondverenbloeifactorharrietkollen keywork-1Eenpondverenbloeifactorharrietkollen keywork-1
Eenpondverenbloeifactorharrietkollen keywork-1Harriet Kollen
 
LA ATENCION
LA ATENCIONLA ATENCION
LA ATENCIONCSG
 
Hệ thống ngân hàng thương mại việt nam và những vấn đề đặt ra
Hệ thống ngân hàng thương mại việt nam và những vấn đề đặt raHệ thống ngân hàng thương mại việt nam và những vấn đề đặt ra
Hệ thống ngân hàng thương mại việt nam và những vấn đề đặt raAskSock Ngô Quang Đạo
 
Barcelona presentacio tampere antirumors
Barcelona presentacio tampere antirumorsBarcelona presentacio tampere antirumors
Barcelona presentacio tampere antirumorsThomas Jézéquel
 
Local Undocumented Migration Policy in the Municipality of Utrecht
Local Undocumented Migration Policy in the Municipality of UtrechtLocal Undocumented Migration Policy in the Municipality of Utrecht
Local Undocumented Migration Policy in the Municipality of UtrechtThomas Jézéquel
 
Javascript classes and scoping
Javascript classes and scopingJavascript classes and scoping
Javascript classes and scopingPatrick Sheridan
 
Migrant Integration in Japan
Migrant Integration in JapanMigrant Integration in Japan
Migrant Integration in JapanThomas Jézéquel
 
2013 09.9 urbact network workshop compressed
2013 09.9 urbact network workshop compressed2013 09.9 urbact network workshop compressed
2013 09.9 urbact network workshop compressedThomas Jézéquel
 
SenchaCon: Sencha Touch Custom Components
SenchaCon: Sencha Touch Custom Components SenchaCon: Sencha Touch Custom Components
SenchaCon: Sencha Touch Custom Components Patrick Sheridan
 

Andere mochten auch (18)

The China Analyst March 2011
The China Analyst   March 2011The China Analyst   March 2011
The China Analyst March 2011
 
tori . michelle . keenan . austun . kevin
tori . michelle . keenan . austun . kevintori . michelle . keenan . austun . kevin
tori . michelle . keenan . austun . kevin
 
SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch
 
Eenpondverenbloeifactorharrietkollen keywork-1
Eenpondverenbloeifactorharrietkollen keywork-1Eenpondverenbloeifactorharrietkollen keywork-1
Eenpondverenbloeifactorharrietkollen keywork-1
 
Teachertube
TeachertubeTeachertube
Teachertube
 
LA ATENCION
LA ATENCIONLA ATENCION
LA ATENCION
 
Hệ thống ngân hàng thương mại việt nam và những vấn đề đặt ra
Hệ thống ngân hàng thương mại việt nam và những vấn đề đặt raHệ thống ngân hàng thương mại việt nam và những vấn đề đặt ra
Hệ thống ngân hàng thương mại việt nam và những vấn đề đặt ra
 
Barcelona presentacio tampere antirumors
Barcelona presentacio tampere antirumorsBarcelona presentacio tampere antirumors
Barcelona presentacio tampere antirumors
 
Local Undocumented Migration Policy in the Municipality of Utrecht
Local Undocumented Migration Policy in the Municipality of UtrechtLocal Undocumented Migration Policy in the Municipality of Utrecht
Local Undocumented Migration Policy in the Municipality of Utrecht
 
Javascript classes and scoping
Javascript classes and scopingJavascript classes and scoping
Javascript classes and scoping
 
Migrant Integration in Japan
Migrant Integration in JapanMigrant Integration in Japan
Migrant Integration in Japan
 
Ciao intro
Ciao introCiao intro
Ciao intro
 
Inforln.com ERP LN 10.3 & 10.4 Configurable Contract Deliverables Enhancements
Inforln.com ERP LN 10.3 & 10.4 Configurable Contract Deliverables EnhancementsInforln.com ERP LN 10.3 & 10.4 Configurable Contract Deliverables Enhancements
Inforln.com ERP LN 10.3 & 10.4 Configurable Contract Deliverables Enhancements
 
Irrp pankratova
Irrp pankratovaIrrp pankratova
Irrp pankratova
 
Quản trị chiến lược chuẩn
Quản trị chiến lược chuẩnQuản trị chiến lược chuẩn
Quản trị chiến lược chuẩn
 
M1 uf1
M1 uf1M1 uf1
M1 uf1
 
2013 09.9 urbact network workshop compressed
2013 09.9 urbact network workshop compressed2013 09.9 urbact network workshop compressed
2013 09.9 urbact network workshop compressed
 
SenchaCon: Sencha Touch Custom Components
SenchaCon: Sencha Touch Custom Components SenchaCon: Sencha Touch Custom Components
SenchaCon: Sencha Touch Custom Components
 

Mehr von Patrick Sheridan

5 new rules for product development
5 new rules for product development5 new rules for product development
5 new rules for product developmentPatrick Sheridan
 
SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch Patrick Sheridan
 
Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...
Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...
Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...Patrick Sheridan
 
Ext JS 4.0 components and layouts
Ext JS 4.0 components and layoutsExt JS 4.0 components and layouts
Ext JS 4.0 components and layoutsPatrick Sheridan
 
Ext JS 4.0 - Creating extensions, plugins and components
Ext JS 4.0 - Creating extensions, plugins and componentsExt JS 4.0 - Creating extensions, plugins and components
Ext JS 4.0 - Creating extensions, plugins and componentsPatrick Sheridan
 
Modus Create Corporate Capabilities
Modus Create Corporate CapabilitiesModus Create Corporate Capabilities
Modus Create Corporate CapabilitiesPatrick Sheridan
 

Mehr von Patrick Sheridan (14)

5 new rules for product development
5 new rules for product development5 new rules for product development
5 new rules for product development
 
SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch SenchaCon: DJing with Sencha Touch
SenchaCon: DJing with Sencha Touch
 
Sencha Touch in Action
Sencha Touch in Action Sencha Touch in Action
Sencha Touch in Action
 
Web audio app preso
Web audio app presoWeb audio app preso
Web audio app preso
 
Rvrsit
RvrsitRvrsit
Rvrsit
 
Discover Music
Discover MusicDiscover Music
Discover Music
 
ExtJS Forms
ExtJS FormsExtJS Forms
ExtJS Forms
 
Intro to sencha touch 2
Intro to sencha touch 2Intro to sencha touch 2
Intro to sencha touch 2
 
HTML5 and Sencha Touch
HTML5 and Sencha TouchHTML5 and Sencha Touch
HTML5 and Sencha Touch
 
Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...
Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...
Using Data Visualization to Create Rich Content Experiences - MarkLogic Webin...
 
Ext JS 4.0 components and layouts
Ext JS 4.0 components and layoutsExt JS 4.0 components and layouts
Ext JS 4.0 components and layouts
 
Ext JS 4.0 - Creating extensions, plugins and components
Ext JS 4.0 - Creating extensions, plugins and componentsExt JS 4.0 - Creating extensions, plugins and components
Ext JS 4.0 - Creating extensions, plugins and components
 
JavaScript Secrets
JavaScript SecretsJavaScript Secrets
JavaScript Secrets
 
Modus Create Corporate Capabilities
Modus Create Corporate CapabilitiesModus Create Corporate Capabilities
Modus Create Corporate Capabilities
 

Kürzlich hochgeladen

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 

Kürzlich hochgeladen (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 

Javascript Performance Tricks

  • 1. JavaScript Performance Tricks Grgur Grisogono - @ggrgur
  • 2. Evaluation eval(foo) vs (new Function(foo))()
  • 3. Evaluation eval(foo) (new Function(foo))() 6,000 5,256 4,500 3,000 1,500 1,081 97 79 110 160 42 47 0 Chrome 21 Firefox 12 IE8 IE7
  • 4. String Concatenation foo = foo + bar foo += bar [].join(’’) 20,000,000 18,817,419 15,000,000 9,940,504 10,000,000 6,348,293 5,000,000 4,503,838 4,191,713 1,359,961 825,543 435,988 347,348 443,218 0 Chrome 21 Firefox 12 IE9 Safari 5 iOS Safari 5.1.1
  • 5. String Concatenation foo = foo + bar foo += bar [].join(’’) foo.concat(bar) 93,236,430 56,781,122 18,817,419 21,484,919 4,503,838 5,878,675 1,320,424 347,348 1,493,283 443,218 Chrome 21 Firefox 12 IE9 Safari 5 iOS Safari 5.1.1
  • 6. String Concatenation foo = foo + bar foo += bar [].join(’’) foo.concat(bar) 93,236,430 56,781,122 21,484,919 9,940,504 6,348,293 4,191,713 5,878,675 435,988 1,320,424 1,359,961 Chrome 21 Firefox 12 IE9 Safari 5 iOS Safari 5.1.1
  • 10. Loops for loop while loop 900,000 675,000 450,000 225,000 0 Chrome 21 Firefox 12 IE9
  • 12. Nested Object Properties deep shallow 60,000,000 45,000,000 30,000,000 15,000,000 0 Chrome 21 Firefox 12 Desktop Safari 5
  • 13. Reuse Array Refs foo = [1] foo.length = 0; foo.push(1) 300,000,000 221,911,826 225,000,000 150,000,000 75,000,000 10,688,860 10,964,912 18,867,925 1,311,286 1,670,314 0 Chrome 21 Firefox 12 IE9
  • 14. Reuse Array Refs foo = [1] foo.length = 0; foo.push(1) 18,867,925 1,670,314 1,311,286 221,911,826 10,964,912 10,688,860 Chrome 21 Firefox 12 IE9
  • 15. Reuse Array Refs foo = [1] foo.length = 0; foo.push(1) 49,678,120 2,493,830 1,030,567 14,644,518 Desktop Safari 5 Mobile Safari iPhone 4S 5.1.1
  • 19. Timers 0 10 ms timer #1 started Time in ms Screen resized 10 Main JS code execution Timer #1 has expired 20 Screen resize event handler 10 ms timer #2 started 30 Timer #1 handler Timer #2 has expired 40 Timer #2 handler 10ms timer #3 started 50 Timer #3 handler
  • 24. Adding Elements To DOM innerHTML DOM methods/replaceChild DOM/cloneNode DocumentFragment 15,000 11,250 7,500 3,750 0 Chrome 21 Firefox 12 IE8 Safari Opera Mobile Safari
  • 26. Updating CSS Styles style cssText 70,000 52,500 35,000 69,621 62,893 58,388 40,058 17,500 0 Chrome 21 Firefox 12
  • 28. Selectors table #menu .first li.first #menu .first #menu > li.first div#div1 table #menu li.first 1,500,000 1,125,000 750,000 375,000 0 Chrome 21 Desktop Safari 5 Firefox 12 IE9

Hinweis der Redaktion

  1. About me - MC, Ext JS in Action SE, History, SDC, Sencha \n
  2. \n
  3. Hard to debug, slow, ... But sometimes necessary (JSON)\nMobile, JSON Decode\n54x faster\nops/sec benchmark.js (jsperf style)\n
  4. Dynamic array creation can be slow\n
  5. \n
  6. \n
  7. \n
  8. \n
  9. a=1 for minimal noise during benchmarks\n
  10. \n
  11. Straight forward, but let’s examine the impact\n
  12. \n
  13. \n
  14. 2000%\n\n
  15. 2000%\n\n
  16. \n
  17. Bubbling - delegation\nCommon for Ext JS / Sencha Touch DataView/List items\n
  18. Bubbling - delegation\nCommon for Ext JS / Sencha Touch DataView/List items\n
  19. Fight the unresponsive dialogue\nVisually speed up long tasks (esp with dom manipulation)\n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. CSS class selectors are the slowest, ID are the fastest\n
  29. \n