SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Your jQuery could perform better

From jQuery-ing
    to jQuery-ing Better
About me

 Project Manager @
 10+ years professional experience
 Microsoft Certified Specialist



 Business Interests
   ASP.NET, AJAX, jQuery
   SOA, Integration
   GIS, Mapping
   SQL optimization
The JavaScript Nature

               Script runs in a single thread (UI thread)
               Shared between JS execution and UI update
Render                         Render                                                   Render
                   <script/>            Download                     Parse   Execute
Started                        Waits                                                   Continued



               Parallel Download is NOT Async Execution


                                                   Modern Browsers
Old Browsers




                 Stop operation                                      Parallel download
                 Download & Execute                                  Execute in order
                 Download next                                       Only one at a time
Blocking Scripts

 Page cannot render until:
   Script is 100% downloaded (longest & variable)
   Parsed (script dependencies)
   Executed




 No UI updates while JavaScript is running
 Long running JS = Unresponsive UI
How long is “Too Long”?
 Performance is critical to success
   Page ranking depends on page speed
   +100ms page load = 1% less Sales
   +2 sec page load = 4% less ad clicks
 Usability
   0.1 sec
       Feel the system is reacting instantaneously
   1.0 sec
       User flow of thought to stay uninterrupted
   10 sec
       The limit for keeping the user's attention
                                     http://www.nngroup.com/articles/response-times-3-important-limits/
Non-blocking Scripts

 Dynamic script loading
   Dynamic script is non-blocking
   Downloaded in parallel
   Execution in the single UI thread
   document.createElement("script")
 Problem?
 Order of script inclusion
   Preserved (Firefox and Opera)
   Not presereved (IE, Safari and Chrome)
Non-blocking Scripts
                    Deferred loading
                   <script defer src=“script.js“/>
                                  Begin download immediately
                                     Execute after UI rendered
                                    DOMContentLoaded event
                 Multiple <script defer> order not guaranteed

 HTML5 async attribute
   <script async src=“script.js“/>
   Supported in IE10
   Download begins immediately
   Execution slotted at first available time (incl. before render)
   Multiple <script async> order not guaranteed
Script Breakup

Breakup long-running scripts
Execute as soon as UI thread is idle
  setTimeout(), setInterval()
  Script yielding
       Example
           var immediateID = setImmediate(function(){…},[params]);
           clearImmediate(immediateID)
 IE (10)         Firefox (19)   Chrome (26)   Safari (6)   Opera (12)
 10+             N/A            N/A           N/A          N/A
JavaScript Concurrency

 HTML5 WebWorkers
      def: separate JS file loaded and executed in the
      background on a separate thread.
 Limitations
      No document
      No page script access
      Data is serialized in/out of worker
      Limited R/O access to most window properties
IE (10)      Firefox (19)   Chrome (26)   Safari (6)   Opera (12)
10+          3.5+           4.0+          4.0+         10.6+
DEMO 1

 Web Workers
A Slide not to Skip
                       Fast and light
                       Document traversal/manipulation
                       Event-handling, animation
                       Simplified AJAX
                       Cross-Browser
 Widespread
   Stable; Tested; Documented; Plugins
   IBM, Google (CDN host), Microsoft (contribute)
 Surprisingly
   All selectors are not created equal
jQuery Selectors

  Selectors are not the same
  Selectors don’t have equal performance
  Main types
Type               Example                  Native Support
ID                 $("#id")                 getElementById()
Element            $("p"), $("input")       getElementsByTagname()
Class              $(".class")              getElementsByClassName()
Attribute          $("[attribute=value]")   querySelectorAll()
Pseudo-Attribute   $(‘:visible, :hidden’)   querySelectorAll()
jsPerf.com

 Create test cases
 Share test cases
 Ops/Sec
   Number of executions per second
   Tests repeated to minimize uncertainty
   Higher is better
 Compare different browser performance
DEMO 2

  ID vs. Element vs. Attribute Selectors
http://jsperf.com/jssatbg-jquery-selector-comparison/2
Sizzling

  Sizzle
      Open source selector library
      From jQuery 1.3 and on
      Right-to-Left parse model
  Make right-most selector specific
  querySelectorAll() in modern browsers
  http://jsperf.com/jssatbg-jquery-sizzling
Rather                     Than
$('.class span.class2')    $('div.class .class2')
Parent-Child Relations

 $parent.find(‘child’) //find
   Parent selector cached from DOM
 $(‘.child’, $parent) //context
   Translated to above (- 5%)
 $parent.children(‘.child’) //immediate children
   Uses $.sibling( elem.firstChild ) (-50%)
 $(‘#parent > .child’) //child combinator
   match child before checking direct parent (-70%)
 $(‘#parent .child’) //class selector
   Uses a class selector, translates to .find() (-75%)
DEMO 3

  Class vs. Context vs. Find()
http://jsperf.com/jssatbg-jquery-selectors/3
Use jQuery When Necessary

 jQuery is JavaScript
 Sometimes JavaScript is better
 Loops
   native for faster than $.each()
 $(this).attr('id')
   Parses selector
   Create jQuery object
   Call document.getElementById()
   90% slower
DEMO 4

  Element Attribute vs. jQuery Attribute
http://jsperf.com/jssatbg-jquery-attributes
CACHING and CHAINing

                  Each $(‘.elem’)
                     reruns searches
                     returns a new collection
                     60% slower
                     Store result and reuse
                      var children1 = $(‘.parents’).find(‘.child’), //bad
                      var parents = $(‘.parents’), //caching
                      var children2 = parents.find(‘.child’); //good
 Chains
   Most jQuery methods support chaining
   Chaining is the fastest followed by cached calls
Events

 Events
   Cost memory
 Attaching events
   $(selector).bind(); // jQuery 1.0
   $(selector).live(); // jQuery 1.3 – 1.9
   $(selector).delegate(); // jQuery 1.4.3+
   $(selector).on(); // jQuery 1.7+
 Example
   Table 8x8
   Typically: 64 event listeners
   $('table').on('click','td', function() {…});
DOM Manipulation

 In-memory vs. On-screen
 Browser redraw is costly
 Insertion
   Minimize .append(), .insertBefore(), .insertAfter()
   Build HTML strings in-memory
   Use single .append()
 .detach()
   On heavy interaction with a node
   Re-insert the node to the DOM once you’re ready
   Up to 60% faster
Other jQuery Tips

 Most important
   Structure
   Maintainability
 Stay up to date
   Regression test
   Know selector performance
 Use HTML 5
   more tags: <section/>, <header/>, <footer/>
   less items with given tag name
   better selector performance
Web Tools
Useful Links
 YUI Compressor
  http://yuicompressor.codeplex.com/
 Browser feature support
  http://caniuse.com/
 Nielsen-Norman Group Usability Articles
  http://www.nngroup.com/articles
 Paul Irish, jQuery Team member
  http://paulirish.com/
 Addy Osmani, Google Engineer and jQuery Team
  http://addyosmani.com/blog/
 John Resig, jQuery Lib Creator
  http://ejohn.org/blog/dom-documentfragments
Expect very soon: SharePoint Saturday!




   Saturday, June 8, 2013
   Same familiar format – 1 day filled with sessions
   focused on SharePoint technologies
   Best SharePoint professionals in the region
   Registrations will be open next week (15th)!
   www.SharePointSaturday.eu
Thanks to our Sponsors:
Diamond Sponsor:



Platinum Sponsors:




Gold Sponsors:



Swag Sponsors:

Media Partners:

Mais conteúdo relacionado

Mais procurados

OSMC 2009 | Application Monitoring - Bridging the gap... by Michael Medin
OSMC 2009 |  Application Monitoring - Bridging the gap... by Michael MedinOSMC 2009 |  Application Monitoring - Bridging the gap... by Michael Medin
OSMC 2009 | Application Monitoring - Bridging the gap... by Michael MedinNETWAYS
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkBorisMoore
 
Developing Applications for WebOS
Developing Applications for WebOSDeveloping Applications for WebOS
Developing Applications for WebOSChuq Von Rospach
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web componentsJarrod Overson
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portlanddmethvin
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widgetTudor Barbu
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOSfpatton
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJsTudor Barbu
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsHolly Schinsky
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriverRajathi-QA
 
Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013
Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013
Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013Joao Lucas Santana
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryAlek Davis
 
Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKBrendan Lim
 
jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)Addy Osmani
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0Takuya Tejima
 

Mais procurados (20)

OSMC 2009 | Application Monitoring - Bridging the gap... by Michael Medin
OSMC 2009 |  Application Monitoring - Bridging the gap... by Michael MedinOSMC 2009 |  Application Monitoring - Bridging the gap... by Michael Medin
OSMC 2009 | Application Monitoring - Bridging the gap... by Michael Medin
 
FuncUnit
FuncUnitFuncUnit
FuncUnit
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
 
Developing Applications for WebOS
Developing Applications for WebOSDeveloping Applications for WebOS
Developing Applications for WebOS
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web components
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portland
 
Selenium
SeleniumSelenium
Selenium
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
 
GWT = easy AJAX
GWT = easy AJAXGWT = easy AJAX
GWT = easy AJAX
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.js
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
iOS and Android apps automation
iOS and Android apps automationiOS and Android apps automation
iOS and Android apps automation
 
Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013
Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013
Um roadmap do Framework Ruby on Rails, do Rails 1 ao Rails 4 - DevDay 2013
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDK
 
jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0
 

Semelhante a Js Saturday 2013 your jQuery could perform better

User Interface Patterns and Nuxeo
User Interface Patterns and NuxeoUser Interface Patterns and Nuxeo
User Interface Patterns and Nuxeoanicewick
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaEr. Sndp Srda
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksThomas Fuchs
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...tdc-globalcode
 
03 Web Events and jQuery
03 Web Events and jQuery03 Web Events and jQuery
03 Web Events and jQuerycrgwbr
 
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitAlex Chaffee
 
jQuery From the Ground Up
jQuery From the Ground UpjQuery From the Ground Up
jQuery From the Ground UpKevin Griffin
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup PerformanceGreg Whalin
 
Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)Artur Cistov
 
7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websitesoazabir
 

Semelhante a Js Saturday 2013 your jQuery could perform better (20)

User Interface Patterns and Nuxeo
User Interface Patterns and NuxeoUser Interface Patterns and Nuxeo
User Interface Patterns and Nuxeo
 
Webpack
Webpack Webpack
Webpack
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep Sharda
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
Web2 - jQuery
Web2 - jQueryWeb2 - jQuery
Web2 - jQuery
 
03 Web Events and jQuery
03 Web Events and jQuery03 Web Events and jQuery
03 Web Events and jQuery
 
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
 
jQuery From the Ground Up
jQuery From the Ground UpjQuery From the Ground Up
jQuery From the Ground Up
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Web driver training
Web driver trainingWeb driver training
Web driver training
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Backbone introduction
Backbone introductionBackbone introduction
Backbone introduction
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)Front-end optimisation & jQuery Internals (Pycon)
Front-end optimisation & jQuery Internals (Pycon)
 
7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites
 

Mais de Ivo Andreev

Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Ivo Andreev
 
Architecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessArchitecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessIvo Andreev
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersIvo Andreev
 
OpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsOpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsIvo Andreev
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneIvo Andreev
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataIvo Andreev
 
Collecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalCollecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalIvo Andreev
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom ModelsIvo Andreev
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosIvo Andreev
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simpleIvo Andreev
 
Constrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiConstrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiIvo Andreev
 
Azure security guidelines for developers
Azure security guidelines for developers Azure security guidelines for developers
Azure security guidelines for developers Ivo Andreev
 
Autonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiAutonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiIvo Andreev
 
Global azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseGlobal azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseIvo Andreev
 
Flux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSFlux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSIvo Andreev
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesIvo Andreev
 
Industrial IoT on Azure
Industrial IoT on AzureIndustrial IoT on Azure
Industrial IoT on AzureIvo Andreev
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkIvo Andreev
 

Mais de Ivo Andreev (20)

Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2
 
Architecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessArchitecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for Business
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
 
OpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsOpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and Misconceptions
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for Everyone
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn Data
 
Collecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalCollecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure Orbital
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom Models
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT Scenarios
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simple
 
Constrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiConstrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project Bonsai
 
Azure security guidelines for developers
Azure security guidelines for developers Azure security guidelines for developers
Azure security guidelines for developers
 
Autonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiAutonomous Machines with Project Bonsai
Autonomous Machines with Project Bonsai
 
Global azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseGlobal azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure Lighthouse
 
Flux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSFlux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JS
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
 
Industrial IoT on Azure
Industrial IoT on AzureIndustrial IoT on Azure
Industrial IoT on Azure
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it Work
 

Último

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 

Último (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 

Js Saturday 2013 your jQuery could perform better

  • 1. Your jQuery could perform better From jQuery-ing to jQuery-ing Better
  • 2. About me Project Manager @ 10+ years professional experience Microsoft Certified Specialist Business Interests ASP.NET, AJAX, jQuery SOA, Integration GIS, Mapping SQL optimization
  • 3. The JavaScript Nature Script runs in a single thread (UI thread) Shared between JS execution and UI update Render Render Render <script/> Download Parse Execute Started Waits Continued Parallel Download is NOT Async Execution Modern Browsers Old Browsers Stop operation Parallel download Download & Execute Execute in order Download next Only one at a time
  • 4. Blocking Scripts Page cannot render until: Script is 100% downloaded (longest & variable) Parsed (script dependencies) Executed No UI updates while JavaScript is running Long running JS = Unresponsive UI
  • 5. How long is “Too Long”? Performance is critical to success Page ranking depends on page speed +100ms page load = 1% less Sales +2 sec page load = 4% less ad clicks Usability 0.1 sec Feel the system is reacting instantaneously 1.0 sec User flow of thought to stay uninterrupted 10 sec The limit for keeping the user's attention http://www.nngroup.com/articles/response-times-3-important-limits/
  • 6. Non-blocking Scripts Dynamic script loading Dynamic script is non-blocking Downloaded in parallel Execution in the single UI thread document.createElement("script") Problem? Order of script inclusion Preserved (Firefox and Opera) Not presereved (IE, Safari and Chrome)
  • 7. Non-blocking Scripts Deferred loading <script defer src=“script.js“/> Begin download immediately Execute after UI rendered DOMContentLoaded event Multiple <script defer> order not guaranteed HTML5 async attribute <script async src=“script.js“/> Supported in IE10 Download begins immediately Execution slotted at first available time (incl. before render) Multiple <script async> order not guaranteed
  • 8. Script Breakup Breakup long-running scripts Execute as soon as UI thread is idle setTimeout(), setInterval() Script yielding Example var immediateID = setImmediate(function(){…},[params]); clearImmediate(immediateID) IE (10) Firefox (19) Chrome (26) Safari (6) Opera (12) 10+ N/A N/A N/A N/A
  • 9. JavaScript Concurrency HTML5 WebWorkers def: separate JS file loaded and executed in the background on a separate thread. Limitations No document No page script access Data is serialized in/out of worker Limited R/O access to most window properties IE (10) Firefox (19) Chrome (26) Safari (6) Opera (12) 10+ 3.5+ 4.0+ 4.0+ 10.6+
  • 10. DEMO 1 Web Workers
  • 11. A Slide not to Skip Fast and light Document traversal/manipulation Event-handling, animation Simplified AJAX Cross-Browser Widespread Stable; Tested; Documented; Plugins IBM, Google (CDN host), Microsoft (contribute) Surprisingly All selectors are not created equal
  • 12. jQuery Selectors Selectors are not the same Selectors don’t have equal performance Main types Type Example Native Support ID $("#id") getElementById() Element $("p"), $("input") getElementsByTagname() Class $(".class") getElementsByClassName() Attribute $("[attribute=value]") querySelectorAll() Pseudo-Attribute $(‘:visible, :hidden’) querySelectorAll()
  • 13. jsPerf.com Create test cases Share test cases Ops/Sec Number of executions per second Tests repeated to minimize uncertainty Higher is better Compare different browser performance
  • 14. DEMO 2 ID vs. Element vs. Attribute Selectors http://jsperf.com/jssatbg-jquery-selector-comparison/2
  • 15. Sizzling Sizzle Open source selector library From jQuery 1.3 and on Right-to-Left parse model Make right-most selector specific querySelectorAll() in modern browsers http://jsperf.com/jssatbg-jquery-sizzling Rather Than $('.class span.class2') $('div.class .class2')
  • 16. Parent-Child Relations $parent.find(‘child’) //find Parent selector cached from DOM $(‘.child’, $parent) //context Translated to above (- 5%) $parent.children(‘.child’) //immediate children Uses $.sibling( elem.firstChild ) (-50%) $(‘#parent > .child’) //child combinator match child before checking direct parent (-70%) $(‘#parent .child’) //class selector Uses a class selector, translates to .find() (-75%)
  • 17. DEMO 3 Class vs. Context vs. Find() http://jsperf.com/jssatbg-jquery-selectors/3
  • 18. Use jQuery When Necessary jQuery is JavaScript Sometimes JavaScript is better Loops native for faster than $.each() $(this).attr('id') Parses selector Create jQuery object Call document.getElementById() 90% slower
  • 19. DEMO 4 Element Attribute vs. jQuery Attribute http://jsperf.com/jssatbg-jquery-attributes
  • 20. CACHING and CHAINing Each $(‘.elem’) reruns searches returns a new collection 60% slower Store result and reuse var children1 = $(‘.parents’).find(‘.child’), //bad var parents = $(‘.parents’), //caching var children2 = parents.find(‘.child’); //good Chains Most jQuery methods support chaining Chaining is the fastest followed by cached calls
  • 21. Events Events Cost memory Attaching events $(selector).bind(); // jQuery 1.0 $(selector).live(); // jQuery 1.3 – 1.9 $(selector).delegate(); // jQuery 1.4.3+ $(selector).on(); // jQuery 1.7+ Example Table 8x8 Typically: 64 event listeners $('table').on('click','td', function() {…});
  • 22. DOM Manipulation In-memory vs. On-screen Browser redraw is costly Insertion Minimize .append(), .insertBefore(), .insertAfter() Build HTML strings in-memory Use single .append() .detach() On heavy interaction with a node Re-insert the node to the DOM once you’re ready Up to 60% faster
  • 23. Other jQuery Tips Most important Structure Maintainability Stay up to date Regression test Know selector performance Use HTML 5 more tags: <section/>, <header/>, <footer/> less items with given tag name better selector performance
  • 25. Useful Links YUI Compressor http://yuicompressor.codeplex.com/ Browser feature support http://caniuse.com/ Nielsen-Norman Group Usability Articles http://www.nngroup.com/articles Paul Irish, jQuery Team member http://paulirish.com/ Addy Osmani, Google Engineer and jQuery Team http://addyosmani.com/blog/ John Resig, jQuery Lib Creator http://ejohn.org/blog/dom-documentfragments
  • 26. Expect very soon: SharePoint Saturday! Saturday, June 8, 2013 Same familiar format – 1 day filled with sessions focused on SharePoint technologies Best SharePoint professionals in the region Registrations will be open next week (15th)! www.SharePointSaturday.eu
  • 27. Thanks to our Sponsors: Diamond Sponsor: Platinum Sponsors: Gold Sponsors: Swag Sponsors: Media Partners: