SlideShare ist ein Scribd-Unternehmen logo
1 von 84
JavaScript Front-End
Performance Optimizations
Northeast JavaScript Conference
LOVE2DEV.COM
My Bio
Microsoft MVP
ASP Insider
Edge User Agent
Web Developer 25 years
Author & Speaker
@ChrisLove
Love2Dev.com
Source Code
http://GitHub.com/
docluv
Slide Deck
http://slideshare.net/docluv/
presentations
10 Days to HTML5 Fitness
http://bit.ly/2ctJMiU
Annoying???
LOVE2DEV.COM
"Also take a step back for a minute and consider the
intent of this change: a faster web is great for
everyone, but especially for users. Lots of websites have
demonstrated that speeding up the user experience
results in more usage. So speeding up your website isn’t
just something that can affect your search rankings–it’s a
fantastic idea for your users.“
http://bit.ly/SPPB4k
Matt Cutts
GOALS
Web Trends & Some History
Front-End Architecture Best Practices
Coding Syntax
Navigation & Performance Timing API
Build & Deploy
LOVE2DEV.COM
Web Trends & History
LOVE2DEV.COM
6 Years of JS Weight Gain
The Reach of JavaScript Expanded
Web Applications/SPAs
HTML5 Games
Basic Web Pages
JavaScript Execution Speed
DOM Interactions
Accelerated Graphics
Page Load Time
Conference Sponsor Sites Performance
LOVE2DEV.COM
Conference Sponsor Sites Averages
LOVE2DEV.COM
• Document Complete 6.94s
• Fully Loaded 8.7s
• Page Weight 2.8MB
• JS Weight 788kb
Web Sites Are Obese &
Out of Shape
http://httpArchive.org as of 5/15/2016
117 File Requests – 2.4+MB
23 JavaScript Files - 401KB
7.1 CSS Files – 74KB
56 Images – 1.577MB
36 TCP Connections
19 Domains
48% Cacheable
Is JavaScript the Problem?
YUI
Total
Size (k)
Number
Elements
CSS
Rules
Image
Files
Script
Lines (F)
Script
Libraries
Site #1 3,697 1,504 1,392 41 77,768
Site #2 2,278 1,100 5,325 29 39,183
Site #3 1,061 2,673 1,105 66 12,643
Site #4 1,812 4,252 1,672 12 10,284
Site #5 1,372 900 3,902 6 38,269
jQuery Prototype ExtJS OtherScriptaculous
YUI
Total
Size (k)
Number
Elements
CSS
Rules
Image
Files
Script
Lines (F)
Script
Libraries
Site #1 3,697 1,504 1,392 41 77,768
Site #2 2,278 1,100 5,325 29 39,183
Site #3 1,061 2,673 1,105 66 12,643
Site #4 1,812 4,252 1,672 12 10,284
Site #5 1,372 900 3,902 6 38,269
jQuery Prototype ExtJS OtherScriptaculous
Fastest
YUI
Total
Size (k)
Number
Elements
CSS
Rules
Image
Files
Script
Lines (F)
Script
Libraries
Site #1 3,697 1,504 1,392 41 77,768
Site #2 2,278 1,100 5,325 29 39,183
Site #3 1,061 2,673 1,105 66 12,643
Site #4 1,812 4,252 1,672 12 10,284
Site #5 1,372 900 3,902 6 38,269
jQuery Prototype ExtJS OtherScriptaculous
Slowest
Is JavaScript the Problem?
• Bytes Must Be Downloaded
• Bytes Cost Real Money
• 25% of US Exceeds Monthly Bandwidth
• Bytes Take Time
• Scripts Must Be Evaluated
• Libraries Can Overwrite Native APIs or Don’t Use Native
APIs
LOVE2DEV.COM
Don’t Guess
• Use Profiling Tools
• Establish Benchmarks
• < 1s Desktop/Broadband
• < 3s Mobile/GPRS
• Test On Real Devices Against ‘Real Site’
• Have a 2G Day
• Apply Scientific Method to Solve Problems
LOVE2DEV.COM
Establish a Performance Culture
• Make Perforamance a 1st Class Citizen of Your Team
• Include Developers, Architects, QA & Stakeholders
• Etsy Quarterly Performance Reports
• https://codeascraft.com/2016/04/28/q1-2016-site-
performance-report/
• Designing For Performance
• http://amzn.to/2d30GRy
Don’t Assume Broadband
What Does Your Site Cost?
http://whatdoesmysitecost.com
Power Consumption
Real & Perceived Performance
Architecture Best Practices
LOVE2DEV.COM
Place Script References At The Bottom
• SCRIPT is a Blocking Action
• Allow Browser to Render As Much As Possible Before
Evaluating & Executing Scripts
JS Parse & Execution Time
• Scripts Must Be Downloaded
• Scripts Must Be Evaluated
• Majority of Traffic from Mobile Class Devices
• Lower Powered CPU
• Less Memory
• Etsy Tool
• https://timkadlec.com/2014/09/js-parse-and-execution-time/
Best Practice
• Ask If Script/Library/Framework Is Really Needed
• Are Their Alternatives?
• Strive to Use Libraries Components That Do What
Needs to be Done
Best Practice – Libraries & Frameworks
• Use A Single Library
• Keep Library Up To Date
• Avoid Duplicate References
• Avoid Duplicate Versions
Avoid Duplicate Code
<html>
<head>
<title>Test</title>
</head>
<body>
…
<script src="jquery.js" … ></script>
<script src="myscript.js" … ></script>
<script src="navigation.js" … ></script>
<script src="jquery.js" … ></script>
</body>
</html>
Avoid Duplicate Code
52%of the pages on the web
have duplicate code
Standardize on Single Library/Framework
<script src="jquery.js" … ></script>
<script src="prototype.js" … ></script>
<script src="dojo.js" … ></script>
<script src="animater.js" … ></script>
<script src="extjs.js" … ></script>
<script src="yahooui.js" … ></script>
<script src="mochikit.js" … ></script>
<script src="lightbox.js" … ></script>
<script src="jslibs.js" … ></script>
<script src=“gsel.js" … ></script>
…
ASP.NET Web Client Library
Prototype
jQuery/jQueryUI
Ember
Angular
React
Ask If It Is Needed
• Avoid Framework Archeology
• Don’t Use a Library/Framework to be Cool
• Resume Driven Development
• Remember the Goal is to Make the Customer Happy
• They Pay the Bills!
• Majority of Pages/Sites are Still Read-Only
Use Async & Defer
• Allows Browser to Finish Rendering Cycle
• Use When Script Order is not important
• Use When Script is not needed to render
Audit 3rd Parties
3rd Parties
• Often Added By Marketing Departments
• Use of Tag Managers
• Many Are Not Used by Stakeholders
• Not Part of Application/Site Q/A
• Not Managed By DevOps
• Not Held to SLA
LOVE2DEV.COM
3rd Parties
• You Are Outsourcing Control Of Your Business To A
Supplier You Have Little or No Control
• They Can & Do Have A Big Impact On Your Brand Image
and Engagment
LOVE2DEV.COM
DOM Interactions
• Built In DOM Methods More Efficient
• Avoid Type Conversion
• Avoid DOM Chatiness
LOVE2DEV.COM
DOM Methods More Efficient
• querySelector
• querySelectorAll
• firstElementChild
• nextElementSibling
• previousElementSibling
• lastElementChild
• childElementCount
LOVE2DEV.COM
function InsertUsername()
{
document.getElementById('user').innerHTML = userName;
}
User .innerHTML to Construct Your Page
Use DOM Efficiently
function InsertUsername()
{
document.getElementById('user').innerHTML = userName;
}
User .innerHTML to Construct Your Page
Use DOM Efficiently
function BuildUI() {
var elm = document.getElementById('ui');
var contents = BuildTitle() + BuildBody() + BuildFooter();
elm.innerHTML = contents;
}
Batch Markup Changes
Use DOM Efficiently
function BuildUI() {
var elm = document.getElementById('ui');
var contents = BuildTitle() + BuildBody() + BuildFooter();
elm.innerHTML = contents;
}
Batch Markup Changes
Use DOM Efficiently
function BuildUI() {
var elm = document.getElementById('ui');
var contents = BuildTitle() + BuildBody() + BuildFooter();
elm.innerHTML = contents;
}
Batch Markup Changes
Use DOM Efficiently
function BuildUI() {
var elm = document.getElementById('ui');
var contents = BuildTitle() + BuildBody() + BuildFooter();
elm.innerHTML = contents;
}
Batch Markup Changes
Use DOM Efficiently
Small Healthy DOM
LOVE2DEV.COM
Use DOM Methods to Create Collections
LOVE2DEV.COM
Use DOM Selectors Collection Access
LOVE2DEV.COM
Avoid DOM Type Conversion
Avoid DOM Chatiness
Performance
• UI Responsiveness
• Identify CPU Intensive Code
• Identify Frame Rate Issues
• JavaScript Profiling
• Identify Code Bottlenecks
LOVE2DEV.COM
Memory Profiling
Memory Profiling
• Timeline to Identify Memory Pressure Issues
• Track Down Memory Leaks
LOVE2DEV.COM
Memory Utilization
Memory Leaks
Memory Leaks
Memory Leaks
Array Best Practices
• Pre-Allocate
• Keep Array Type Consistent
• Use Typed Arrays
• Keep Arrays Dense
• Enumerate Efficiently
LOVE2DEV.COM
Use Typed Arrays
LOVE2DEV.COM
Sparse vs Dense Arrays
• Arrays are Sparse, they have holes in them
• A map from indices to values
LOVE2DEV.COM
Sparse vs Dense Arrays
var a = new Array(3);
a [ , , ];
a.length === 3
a[0] === undefined
a.map(function (x, i) { return i }) === [ , , ]
LOVE2DEV.COM
Sparse vs Dense Arrays
• Array(undefined, undefined, undefined)
• a.map(function (x, i) { return i }) === [ 0, 1, 2 ]
LOVE2DEV.COM
Keep Arrays Dense
LOVE2DEV.COM
Enumerate Arrays Efficently
LOVE2DEV.COM
Don’t do useless work
setInterval(draw, 0);
setTimeout(draw, 0);
requestAnimationFrame(draw);
setTimeout(draw, 1000 / 60);
Do avoid chattiness with the DOM
JavaScript
DOM
for (var i = 0; i < this.nOfBubbles; i++) {
document.body.box.getElementById("ball0").style.left = b.x + "px";
document.body.box.getElementById("ball0").style.top = b.y + "px";
}
Do check types of values from DOM
this.nOfBubbles = document.getElementById(“dropDown").value;
30%
of rendering time in string conversion
Slow Operations
11%
Value Conversions
18%
GC 17%
Your Code 45%
JavaScript: Flexibility or performance
Flexibility Performance
“Think C++”“Think Script”
Simple Websites Complex Apps, Games
var r = 3 * "10"; // r == 300
var a = new Array();
a.push(10);
var p = {x: 0, y: 0};
p.z = 5;
p["some text"] = 1;
p[1] = 2;
eval("var s = p[1] * a[0]"); // s == 20
var r = 3 * parseInt("10");
var a = new Array(100);
a[0] = 10;
var p = new Point(0, 0, 0);
p.z = 5;
• C, C++, C# (Static Language)
• static int DoMath(int value) {
• int result = 0;
• for (int i = 0; i < 10000; i++) {
• for (int j = 0; j < 10000; j++)
{
• result = i + j + value;
• }
• }
• return result;
• }
JavaScript (Dynamic Language)
function DoMath(value) {
for (var i = 0; i < 10000; i++) {
for (var j = 0; j < 10000; j++) {
var result = i + j + value;
}
}
return result;
}
Stick to Integer Math
Write Fast JavaScript
Stick to Integer Math
Write Fast JavaScript
C++ JavaScript
DoMath(999);
40ms
200ms (~5x)
DoMath(999/2);
40ms
1600ms (~40x)
Stick to Integer Math
Write Fast JavaScript
0x005e22a0
Pointer
01
Type Tag
449.4999999……
…
Value
02
Type Tag
“Hello World”
Value
0x005e4148
Pointer
Stick to Integer Math
Write Fast JavaScript
DoMath(Math.floor(999 / 2));
var b = Math.ceil((p[i].r + p[i].g + p[i].b) / 3);
Stick to Integer Math
Write Fast JavaScript
DoMath(Math.floor(999 / 2));
var b = Math.ceil((p[i].r + p[i].g + p[i].b) / 3);
Stick to Integer Math
Write Fast JavaScript
DoMath(Math.floor(999 / 2));
var b = Math.ceil((p[i].r + p[i].g + p[i].b) / 3);
Do write fast objects
• Add all properties in constructor
• Don’t delete properties
• Use identifiers for property names
• Use getters and setters sparingly
• Avoid conditionally adding properties
• Avoid default property values on prototype objects
Navigation & Performance Timing APIs
• Give You Access to Real Times
• Various Stages of Document Lifecycle
• https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API
• http://www.html5rocks.com/en/tutorials/webperformance/basics/
Navigation & Performance Timing APIs
How to Build JavaScript
• Maintain Development, QA, Production Versions
• Use a Build Tool
• Grunt, Gulp, WebPac, Broccoli, Node, etc
How to Build Production JavaScript
• Bundle & Minify
• A Single Request is much faster to download and parse
• Compress
• Gzip
• Content-Encoding Header
• Set Proper Cache Headers
• CacheControl: "public, max-age=31449600, s-max-age=360“
• Use A CDN
• Host on Static Server
How to Build Production JavaScript
• Node Modules Exists to Automate All these Requirements
• Set it and Forget It!

Weitere ähnliche Inhalte

Was ist angesagt?

Enough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasEnough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasKubide
 
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOSBuilding Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOSFITC
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Timothy Fisher
 
HTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedHTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedPeter Lubbers
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in ComponentsFITC
 
Extreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NYExtreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NYMaximiliano Firtman
 
WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)Shumpei Shiraishi
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server RenderingDavid Amend
 
Developing JavaScript Widgets
Developing JavaScript WidgetsDeveloping JavaScript Widgets
Developing JavaScript WidgetsBob German
 
Grokking #9: Building a real-time and offline editing service with Couchbase
Grokking #9: Building a real-time and offline editing service with CouchbaseGrokking #9: Building a real-time and offline editing service with Couchbase
Grokking #9: Building a real-time and offline editing service with CouchbaseOliver N
 
Engineering the New LinkedIn Profile
Engineering the New LinkedIn ProfileEngineering the New LinkedIn Profile
Engineering the New LinkedIn ProfileJosh Clemm
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page appsThomas Heymann
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web AppsFITC
 
The fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactThe fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactOliver N
 
Build Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićBuild Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićMeetMagentoNY2014
 
An Introduction to webOS
An Introduction to webOSAn Introduction to webOS
An Introduction to webOSKevin Decker
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a proMarko Heijnen
 

Was ist angesagt? (20)

Enough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasEnough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas Zakas
 
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOSBuilding Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 
HTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedHTML5 Web Workers-unleashed
HTML5 Web Workers-unleashed
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Extreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NYExtreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NY
 
WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server Rendering
 
Developing JavaScript Widgets
Developing JavaScript WidgetsDeveloping JavaScript Widgets
Developing JavaScript Widgets
 
Grokking #9: Building a real-time and offline editing service with Couchbase
Grokking #9: Building a real-time and offline editing service with CouchbaseGrokking #9: Building a real-time and offline editing service with Couchbase
Grokking #9: Building a real-time and offline editing service with Couchbase
 
Engineering the New LinkedIn Profile
Engineering the New LinkedIn ProfileEngineering the New LinkedIn Profile
Engineering the New LinkedIn Profile
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page apps
 
The MEAN Stack
The MEAN StackThe MEAN Stack
The MEAN Stack
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
The fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactThe fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose React
 
Build Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićBuild Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje Jurišić
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
 
An Introduction to webOS
An Introduction to webOSAn Introduction to webOS
An Introduction to webOS
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
 

Ähnlich wie JavaScript front end performance optimizations

Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web AppsTimothy Fisher
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery GuideMark Rackley
 
The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14Mark Rackley
 
BrazilJS Perf Doctor Talk
BrazilJS Perf Doctor TalkBrazilJS Perf Doctor Talk
BrazilJS Perf Doctor TalkJosh Holmes
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutionswoutervugt
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to JqueryGurpreet singh
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Sadaaki HIRAI
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX DesignersAshlimarie
 
Top 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | EdurekaTop 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | EdurekaEdureka!
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"Binary Studio
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesDoris Chen
 
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB
 

Ähnlich wie JavaScript front end performance optimizations (20)

Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide
 
The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
BrazilJS Perf Doctor Talk
BrazilJS Perf Doctor TalkBrazilJS Perf Doctor Talk
BrazilJS Perf Doctor Talk
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutions
 
Coding the UI
Coding the UICoding the UI
Coding the UI
 
Coding Ui
Coding UiCoding Ui
Coding Ui
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Top 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | EdurekaTop 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | Edureka
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"
 
HTML5.pptx
HTML5.pptxHTML5.pptx
HTML5.pptx
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best Practices
 
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch Tutorial
 

Mehr von Chris Love

Quick Fetch API Introduction
Quick Fetch API IntroductionQuick Fetch API Introduction
Quick Fetch API IntroductionChris Love
 
Introduction to Progressive Web Applications
Introduction to Progressive Web ApplicationsIntroduction to Progressive Web Applications
Introduction to Progressive Web ApplicationsChris Love
 
Introduction to Progressive Web Applications
Introduction to Progressive Web ApplicationsIntroduction to Progressive Web Applications
Introduction to Progressive Web ApplicationsChris Love
 
Lazy load Website Assets
Lazy load Website AssetsLazy load Website Assets
Lazy load Website AssetsChris Love
 
Progressive Web Apps for Education
Progressive Web Apps for EducationProgressive Web Apps for Education
Progressive Web Apps for EducationChris Love
 
The server is dead going serverless to create a highly scalable application y...
The server is dead going serverless to create a highly scalable application y...The server is dead going serverless to create a highly scalable application y...
The server is dead going serverless to create a highly scalable application y...Chris Love
 
A Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsA Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsChris Love
 
Real World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker CachingReal World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker CachingChris Love
 
Using Responsive Web Design To Make Your Web Work Everywhere - Updated
Using Responsive Web Design To Make Your Web Work Everywhere - UpdatedUsing Responsive Web Design To Make Your Web Work Everywhere - Updated
Using Responsive Web Design To Make Your Web Work Everywhere - UpdatedChris Love
 
Implementing a Responsive Image Strategy
Implementing a Responsive Image StrategyImplementing a Responsive Image Strategy
Implementing a Responsive Image StrategyChris Love
 
Using Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work EverywhereUsing Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work EverywhereChris Love
 
10 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 201610 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 2016Chris Love
 
Css best practices style guide and tips
Css best practices style guide and tipsCss best practices style guide and tips
Css best practices style guide and tipsChris Love
 
Using Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work Everywhere Using Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work Everywhere Chris Love
 
An Introduction to Microsoft Edge
An Introduction to Microsoft EdgeAn Introduction to Microsoft Edge
An Introduction to Microsoft EdgeChris Love
 
10 things you can do to speed up your web app today stir trek edition
10 things you can do to speed up your web app today   stir trek edition10 things you can do to speed up your web app today   stir trek edition
10 things you can do to speed up your web app today stir trek editionChris Love
 
Single page applications the basics
Single page applications the basicsSingle page applications the basics
Single page applications the basicsChris Love
 
There Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web DesignThere Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web DesignChris Love
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App TodayChris Love
 

Mehr von Chris Love (20)

Quick Fetch API Introduction
Quick Fetch API IntroductionQuick Fetch API Introduction
Quick Fetch API Introduction
 
Introduction to Progressive Web Applications
Introduction to Progressive Web ApplicationsIntroduction to Progressive Web Applications
Introduction to Progressive Web Applications
 
Introduction to Progressive Web Applications
Introduction to Progressive Web ApplicationsIntroduction to Progressive Web Applications
Introduction to Progressive Web Applications
 
Lazy load Website Assets
Lazy load Website AssetsLazy load Website Assets
Lazy load Website Assets
 
Progressive Web Apps for Education
Progressive Web Apps for EducationProgressive Web Apps for Education
Progressive Web Apps for Education
 
The server is dead going serverless to create a highly scalable application y...
The server is dead going serverless to create a highly scalable application y...The server is dead going serverless to create a highly scalable application y...
The server is dead going serverless to create a highly scalable application y...
 
A Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsA Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page Applications
 
Real World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker CachingReal World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker Caching
 
Using Responsive Web Design To Make Your Web Work Everywhere - Updated
Using Responsive Web Design To Make Your Web Work Everywhere - UpdatedUsing Responsive Web Design To Make Your Web Work Everywhere - Updated
Using Responsive Web Design To Make Your Web Work Everywhere - Updated
 
Implementing a Responsive Image Strategy
Implementing a Responsive Image StrategyImplementing a Responsive Image Strategy
Implementing a Responsive Image Strategy
 
Using Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work EverywhereUsing Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work Everywhere
 
10 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 201610 things you can do to speed up your web app today 2016
10 things you can do to speed up your web app today 2016
 
Css best practices style guide and tips
Css best practices style guide and tipsCss best practices style guide and tips
Css best practices style guide and tips
 
Using Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work Everywhere Using Responsive Web Design To Make Your Web Work Everywhere
Using Responsive Web Design To Make Your Web Work Everywhere
 
An Introduction to Microsoft Edge
An Introduction to Microsoft EdgeAn Introduction to Microsoft Edge
An Introduction to Microsoft Edge
 
10 things you can do to speed up your web app today stir trek edition
10 things you can do to speed up your web app today   stir trek edition10 things you can do to speed up your web app today   stir trek edition
10 things you can do to speed up your web app today stir trek edition
 
Single page applications the basics
Single page applications the basicsSingle page applications the basics
Single page applications the basics
 
There Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web DesignThere Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web Design
 
Touch the web
Touch the webTouch the web
Touch the web
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today
 

Kürzlich hochgeladen

pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理F
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsMonica Sydney
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制pxcywzqs
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Balliameghakumariji156
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理F
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoilmeghakumariji156
 
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...meghakumariji156
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查ydyuyu
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdfMatthew Sinclair
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasDigicorns Technologies
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsMonica Sydney
 
Mira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call GirlsMira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call GirlsPriya Reddy
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiMonica Sydney
 

Kürzlich hochgeladen (20)

pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
Mira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call GirlsMira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
 

JavaScript front end performance optimizations

  • 1. JavaScript Front-End Performance Optimizations Northeast JavaScript Conference LOVE2DEV.COM
  • 2. My Bio Microsoft MVP ASP Insider Edge User Agent Web Developer 25 years Author & Speaker @ChrisLove Love2Dev.com
  • 4. 10 Days to HTML5 Fitness http://bit.ly/2ctJMiU
  • 5.
  • 7. LOVE2DEV.COM "Also take a step back for a minute and consider the intent of this change: a faster web is great for everyone, but especially for users. Lots of websites have demonstrated that speeding up the user experience results in more usage. So speeding up your website isn’t just something that can affect your search rankings–it’s a fantastic idea for your users.“ http://bit.ly/SPPB4k Matt Cutts
  • 8. GOALS Web Trends & Some History Front-End Architecture Best Practices Coding Syntax Navigation & Performance Timing API Build & Deploy LOVE2DEV.COM
  • 9. Web Trends & History LOVE2DEV.COM
  • 10. 6 Years of JS Weight Gain
  • 11. The Reach of JavaScript Expanded Web Applications/SPAs HTML5 Games Basic Web Pages JavaScript Execution Speed DOM Interactions Accelerated Graphics Page Load Time
  • 12. Conference Sponsor Sites Performance LOVE2DEV.COM
  • 13. Conference Sponsor Sites Averages LOVE2DEV.COM • Document Complete 6.94s • Fully Loaded 8.7s • Page Weight 2.8MB • JS Weight 788kb
  • 14. Web Sites Are Obese & Out of Shape http://httpArchive.org as of 5/15/2016 117 File Requests – 2.4+MB 23 JavaScript Files - 401KB 7.1 CSS Files – 74KB 56 Images – 1.577MB 36 TCP Connections 19 Domains 48% Cacheable
  • 15. Is JavaScript the Problem?
  • 16.
  • 17. YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,697 1,504 1,392 41 77,768 Site #2 2,278 1,100 5,325 29 39,183 Site #3 1,061 2,673 1,105 66 12,643 Site #4 1,812 4,252 1,672 12 10,284 Site #5 1,372 900 3,902 6 38,269 jQuery Prototype ExtJS OtherScriptaculous
  • 18. YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,697 1,504 1,392 41 77,768 Site #2 2,278 1,100 5,325 29 39,183 Site #3 1,061 2,673 1,105 66 12,643 Site #4 1,812 4,252 1,672 12 10,284 Site #5 1,372 900 3,902 6 38,269 jQuery Prototype ExtJS OtherScriptaculous Fastest
  • 19. YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,697 1,504 1,392 41 77,768 Site #2 2,278 1,100 5,325 29 39,183 Site #3 1,061 2,673 1,105 66 12,643 Site #4 1,812 4,252 1,672 12 10,284 Site #5 1,372 900 3,902 6 38,269 jQuery Prototype ExtJS OtherScriptaculous Slowest
  • 20. Is JavaScript the Problem? • Bytes Must Be Downloaded • Bytes Cost Real Money • 25% of US Exceeds Monthly Bandwidth • Bytes Take Time • Scripts Must Be Evaluated • Libraries Can Overwrite Native APIs or Don’t Use Native APIs LOVE2DEV.COM
  • 21. Don’t Guess • Use Profiling Tools • Establish Benchmarks • < 1s Desktop/Broadband • < 3s Mobile/GPRS • Test On Real Devices Against ‘Real Site’ • Have a 2G Day • Apply Scientific Method to Solve Problems LOVE2DEV.COM
  • 22. Establish a Performance Culture • Make Perforamance a 1st Class Citizen of Your Team • Include Developers, Architects, QA & Stakeholders • Etsy Quarterly Performance Reports • https://codeascraft.com/2016/04/28/q1-2016-site- performance-report/ • Designing For Performance • http://amzn.to/2d30GRy
  • 24. What Does Your Site Cost? http://whatdoesmysitecost.com
  • 26. Real & Perceived Performance
  • 28. Place Script References At The Bottom • SCRIPT is a Blocking Action • Allow Browser to Render As Much As Possible Before Evaluating & Executing Scripts
  • 29. JS Parse & Execution Time • Scripts Must Be Downloaded • Scripts Must Be Evaluated • Majority of Traffic from Mobile Class Devices • Lower Powered CPU • Less Memory • Etsy Tool • https://timkadlec.com/2014/09/js-parse-and-execution-time/
  • 30.
  • 31. Best Practice • Ask If Script/Library/Framework Is Really Needed • Are Their Alternatives? • Strive to Use Libraries Components That Do What Needs to be Done
  • 32. Best Practice – Libraries & Frameworks • Use A Single Library • Keep Library Up To Date • Avoid Duplicate References • Avoid Duplicate Versions
  • 33. Avoid Duplicate Code <html> <head> <title>Test</title> </head> <body> … <script src="jquery.js" … ></script> <script src="myscript.js" … ></script> <script src="navigation.js" … ></script> <script src="jquery.js" … ></script> </body> </html>
  • 34. Avoid Duplicate Code 52%of the pages on the web have duplicate code
  • 35. Standardize on Single Library/Framework <script src="jquery.js" … ></script> <script src="prototype.js" … ></script> <script src="dojo.js" … ></script> <script src="animater.js" … ></script> <script src="extjs.js" … ></script> <script src="yahooui.js" … ></script> <script src="mochikit.js" … ></script> <script src="lightbox.js" … ></script> <script src="jslibs.js" … ></script> <script src=“gsel.js" … ></script> …
  • 36. ASP.NET Web Client Library Prototype jQuery/jQueryUI Ember Angular React
  • 37. Ask If It Is Needed • Avoid Framework Archeology • Don’t Use a Library/Framework to be Cool • Resume Driven Development • Remember the Goal is to Make the Customer Happy • They Pay the Bills! • Majority of Pages/Sites are Still Read-Only
  • 38. Use Async & Defer • Allows Browser to Finish Rendering Cycle • Use When Script Order is not important • Use When Script is not needed to render
  • 40. 3rd Parties • Often Added By Marketing Departments • Use of Tag Managers • Many Are Not Used by Stakeholders • Not Part of Application/Site Q/A • Not Managed By DevOps • Not Held to SLA LOVE2DEV.COM
  • 41. 3rd Parties • You Are Outsourcing Control Of Your Business To A Supplier You Have Little or No Control • They Can & Do Have A Big Impact On Your Brand Image and Engagment LOVE2DEV.COM
  • 42. DOM Interactions • Built In DOM Methods More Efficient • Avoid Type Conversion • Avoid DOM Chatiness LOVE2DEV.COM
  • 43. DOM Methods More Efficient • querySelector • querySelectorAll • firstElementChild • nextElementSibling • previousElementSibling • lastElementChild • childElementCount LOVE2DEV.COM
  • 44. function InsertUsername() { document.getElementById('user').innerHTML = userName; } User .innerHTML to Construct Your Page Use DOM Efficiently
  • 45. function InsertUsername() { document.getElementById('user').innerHTML = userName; } User .innerHTML to Construct Your Page Use DOM Efficiently
  • 46. function BuildUI() { var elm = document.getElementById('ui'); var contents = BuildTitle() + BuildBody() + BuildFooter(); elm.innerHTML = contents; } Batch Markup Changes Use DOM Efficiently
  • 47. function BuildUI() { var elm = document.getElementById('ui'); var contents = BuildTitle() + BuildBody() + BuildFooter(); elm.innerHTML = contents; } Batch Markup Changes Use DOM Efficiently
  • 48. function BuildUI() { var elm = document.getElementById('ui'); var contents = BuildTitle() + BuildBody() + BuildFooter(); elm.innerHTML = contents; } Batch Markup Changes Use DOM Efficiently
  • 49. function BuildUI() { var elm = document.getElementById('ui'); var contents = BuildTitle() + BuildBody() + BuildFooter(); elm.innerHTML = contents; } Batch Markup Changes Use DOM Efficiently
  • 51. Use DOM Methods to Create Collections LOVE2DEV.COM
  • 52. Use DOM Selectors Collection Access LOVE2DEV.COM
  • 53. Avoid DOM Type Conversion
  • 55. Performance • UI Responsiveness • Identify CPU Intensive Code • Identify Frame Rate Issues • JavaScript Profiling • Identify Code Bottlenecks LOVE2DEV.COM
  • 57. Memory Profiling • Timeline to Identify Memory Pressure Issues • Track Down Memory Leaks LOVE2DEV.COM
  • 62. Array Best Practices • Pre-Allocate • Keep Array Type Consistent • Use Typed Arrays • Keep Arrays Dense • Enumerate Efficiently LOVE2DEV.COM
  • 64. Sparse vs Dense Arrays • Arrays are Sparse, they have holes in them • A map from indices to values LOVE2DEV.COM
  • 65. Sparse vs Dense Arrays var a = new Array(3); a [ , , ]; a.length === 3 a[0] === undefined a.map(function (x, i) { return i }) === [ , , ] LOVE2DEV.COM
  • 66. Sparse vs Dense Arrays • Array(undefined, undefined, undefined) • a.map(function (x, i) { return i }) === [ 0, 1, 2 ] LOVE2DEV.COM
  • 69. Don’t do useless work setInterval(draw, 0); setTimeout(draw, 0); requestAnimationFrame(draw); setTimeout(draw, 1000 / 60);
  • 70. Do avoid chattiness with the DOM JavaScript DOM for (var i = 0; i < this.nOfBubbles; i++) { document.body.box.getElementById("ball0").style.left = b.x + "px"; document.body.box.getElementById("ball0").style.top = b.y + "px"; }
  • 71. Do check types of values from DOM this.nOfBubbles = document.getElementById(“dropDown").value; 30% of rendering time in string conversion Slow Operations 11% Value Conversions 18% GC 17% Your Code 45%
  • 72. JavaScript: Flexibility or performance Flexibility Performance “Think C++”“Think Script” Simple Websites Complex Apps, Games var r = 3 * "10"; // r == 300 var a = new Array(); a.push(10); var p = {x: 0, y: 0}; p.z = 5; p["some text"] = 1; p[1] = 2; eval("var s = p[1] * a[0]"); // s == 20 var r = 3 * parseInt("10"); var a = new Array(100); a[0] = 10; var p = new Point(0, 0, 0); p.z = 5;
  • 73. • C, C++, C# (Static Language) • static int DoMath(int value) { • int result = 0; • for (int i = 0; i < 10000; i++) { • for (int j = 0; j < 10000; j++) { • result = i + j + value; • } • } • return result; • } JavaScript (Dynamic Language) function DoMath(value) { for (var i = 0; i < 10000; i++) { for (var j = 0; j < 10000; j++) { var result = i + j + value; } } return result; } Stick to Integer Math Write Fast JavaScript
  • 74. Stick to Integer Math Write Fast JavaScript C++ JavaScript DoMath(999); 40ms 200ms (~5x) DoMath(999/2); 40ms 1600ms (~40x)
  • 75. Stick to Integer Math Write Fast JavaScript 0x005e22a0 Pointer 01 Type Tag 449.4999999…… … Value 02 Type Tag “Hello World” Value 0x005e4148 Pointer
  • 76. Stick to Integer Math Write Fast JavaScript DoMath(Math.floor(999 / 2)); var b = Math.ceil((p[i].r + p[i].g + p[i].b) / 3);
  • 77. Stick to Integer Math Write Fast JavaScript DoMath(Math.floor(999 / 2)); var b = Math.ceil((p[i].r + p[i].g + p[i].b) / 3);
  • 78. Stick to Integer Math Write Fast JavaScript DoMath(Math.floor(999 / 2)); var b = Math.ceil((p[i].r + p[i].g + p[i].b) / 3);
  • 79. Do write fast objects • Add all properties in constructor • Don’t delete properties • Use identifiers for property names • Use getters and setters sparingly • Avoid conditionally adding properties • Avoid default property values on prototype objects
  • 80. Navigation & Performance Timing APIs • Give You Access to Real Times • Various Stages of Document Lifecycle • https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API • http://www.html5rocks.com/en/tutorials/webperformance/basics/
  • 82. How to Build JavaScript • Maintain Development, QA, Production Versions • Use a Build Tool • Grunt, Gulp, WebPac, Broccoli, Node, etc
  • 83. How to Build Production JavaScript • Bundle & Minify • A Single Request is much faster to download and parse • Compress • Gzip • Content-Encoding Header • Set Proper Cache Headers • CacheControl: "public, max-age=31449600, s-max-age=360“ • Use A CDN • Host on Static Server
  • 84. How to Build Production JavaScript • Node Modules Exists to Automate All these Requirements • Set it and Forget It!

Hinweis der Redaktion

  1. Update these #s before the presentation as they are always updating