SlideShare a Scribd company logo
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:

More Related Content

What's hot (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
NETWAYS
 
FuncUnit
FuncUnitFuncUnit
FuncUnit
Brian Moschel
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
BorisMoore
 
Developing Applications for WebOS
Developing Applications for WebOSDeveloping Applications for WebOS
Developing Applications for WebOS
Chuq Von Rospach
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web components
Jarrod Overson
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portland
dmethvin
 
Selenium
SeleniumSelenium
Selenium
husnara mohammad
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
Anil Kumar
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
Tudor Barbu
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
fpatton
 
GWT = easy AJAX
GWT = easy AJAXGWT = easy AJAX
GWT = easy AJAX
Olivier Gérardin
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor 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.js
Holly Schinsky
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
Rajathi-QA
 
iOS and Android apps automation
iOS and Android apps automationiOS and Android apps automation
iOS and Android apps automation
Sridhar Ramakrishnan
 
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
Joao Lucas Santana
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Alek Davis
 
Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDK
Brendan 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.0
Takuya Tejima
 
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
NETWAYS
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
BorisMoore
 
Developing Applications for WebOS
Developing Applications for WebOSDeveloping Applications for WebOS
Developing Applications for WebOS
Chuq Von Rospach
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web components
Jarrod Overson
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portland
dmethvin
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
Anil Kumar
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
Tudor Barbu
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
fpatton
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor 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.js
Holly Schinsky
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
Rajathi-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 2013
Joao Lucas Santana
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Alek Davis
 
Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDK
Brendan 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.0
Takuya Tejima
 

Similar to 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
anicewick
 
Webpack
Webpack Webpack
Webpack
Sofian Hadiwijaya
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep Sharda
Er. Sndp Srda
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
Ioan Eugen Stan
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
Dina Goldshtein
 
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
Thomas 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
 
Web2 - jQuery
Web2 - jQueryWeb2 - jQuery
Web2 - jQuery
voicerepublic
 
03 Web Events and jQuery
03 Web Events and jQuery03 Web Events and jQuery
03 Web Events and jQuery
crgwbr
 
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
Alex Chaffee
 
jQuery From the Ground Up
jQuery From the Ground UpjQuery From the Ground Up
jQuery From the Ground Up
Kevin Griffin
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Nivedhitha Venugopal
 
Web driver training
Web driver trainingWeb driver training
Web driver training
Dipesh Bhatewara
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
Yan Shi
 
Backbone introduction
Backbone introductionBackbone introduction
Backbone introduction
Ravi Kumar Hamsa
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
Justin Cataldo
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
Greg 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 websites
oazabir
 
User Interface Patterns and Nuxeo
User Interface Patterns and NuxeoUser Interface Patterns and Nuxeo
User Interface Patterns and Nuxeo
anicewick
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep Sharda
Er. Sndp Srda
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
Ioan 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-Frameworks
Thomas 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 jQuery
crgwbr
 
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
Alex Chaffee
 
jQuery From the Ground Up
jQuery From the Ground UpjQuery From the Ground Up
jQuery From the Ground Up
Kevin Griffin
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
Yan Shi
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
Greg 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 websites
oazabir
 

More from Ivo Andreev (20)

LLM-based Multi-Agent Systems to Replace Traditional Software
LLM-based Multi-Agent Systems to Replace Traditional SoftwareLLM-based Multi-Agent Systems to Replace Traditional Software
LLM-based Multi-Agent Systems to Replace Traditional Software
Ivo Andreev
 
LLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protectedLLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protected
Ivo Andreev
 
What are Phi Small Language Models Capable of
What are Phi Small Language Models Capable ofWhat are Phi Small Language Models Capable of
What are Phi Small Language Models Capable of
Ivo Andreev
 
Autonomous Control AI Training from Data
Autonomous Control AI Training from DataAutonomous Control AI Training from Data
Autonomous Control AI Training from Data
Ivo Andreev
 
Autonomous Systems for Optimization and Control
Autonomous Systems for Optimization and ControlAutonomous Systems for Optimization and Control
Autonomous Systems for Optimization and Control
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.2
Ivo 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 Business
Ivo 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 Bad
Ivo Andreev
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
Ivo 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 Developers
Ivo 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 Misconceptions
Ivo Andreev
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for Everyone
Ivo Andreev
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn Data
Ivo 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 Orbital
Ivo Andreev
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom Models
Ivo Andreev
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT Scenarios
Ivo Andreev
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simple
Ivo 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 Bonsai
Ivo 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 Bonsai
Ivo Andreev
 
LLM-based Multi-Agent Systems to Replace Traditional Software
LLM-based Multi-Agent Systems to Replace Traditional SoftwareLLM-based Multi-Agent Systems to Replace Traditional Software
LLM-based Multi-Agent Systems to Replace Traditional Software
Ivo Andreev
 
LLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protectedLLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protected
Ivo Andreev
 
What are Phi Small Language Models Capable of
What are Phi Small Language Models Capable ofWhat are Phi Small Language Models Capable of
What are Phi Small Language Models Capable of
Ivo Andreev
 
Autonomous Control AI Training from Data
Autonomous Control AI Training from DataAutonomous Control AI Training from Data
Autonomous Control AI Training from Data
Ivo Andreev
 
Autonomous Systems for Optimization and Control
Autonomous Systems for Optimization and ControlAutonomous Systems for Optimization and Control
Autonomous Systems for Optimization and Control
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.2
Ivo 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 Business
Ivo 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 Bad
Ivo Andreev
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
Ivo 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 Developers
Ivo 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 Misconceptions
Ivo Andreev
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for Everyone
Ivo Andreev
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn Data
Ivo 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 Orbital
Ivo Andreev
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom Models
Ivo Andreev
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT Scenarios
Ivo Andreev
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simple
Ivo 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 Bonsai
Ivo 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 Bonsai
Ivo Andreev
 

Recently uploaded (20)

FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 

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: