Windows 8 Windows Core OS Services JavaScript (Chakra) C C++ C# VB Windows Store Apps Communication & Data Application Model Devices & Printing WinRT.

Slides:



Advertisements
Similar presentations
Building Fast 3rd-Party Webapps O'Reilly Velocity Web Performance and Operations Conference 24 June Lessons.
Advertisements

Web Performance Meetup 1 Web Performance 101 Jeremy
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
CHAPTER 15 WEBPAGE OPTIMIZATION. LEARNING OBJECTIVES How to test your web-page performance How browser and server interactions impact performance What.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
Project 1 Introduction to HTML.
HTTP – HyperText Transfer Protocol
Building A Fast Web Experience Internet Explorer 9 Is All Around Fast Sandeep J Alur Microsoft India.
How the web works: HTTP and CGI explained
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
Introduction to HTML 2006 INT197B. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
High Performance Websites (Based on Steve Souder’s lecture) By Bhoomi Patel.
High-Performance Best Practices for Web Sites Jason Weber, Internet Explorer Team, Microsoft.
1st Project Introduction to HTML.
Mark Phillip markphillip.com 200s, 304s, Expires Headers, HTTP Compression, And You.
HTML 1 Introduction to HTML. 2 Objectives Describe the Internet and its associated key terms Describe the World Wide Web and its associated key terms.
Chapter ONE Introduction to HTML.
TUTORIAL 8: Enhancing a Web Site with Advanced CSS
 Using Microsoft Expression Web you can: › Create Web pages and Web sites › Set what you site will look like as you design it › Add text, images, multimedia.
INTRODUCTION TO DHTML. TOPICS TO BE DISCUSSED……….  Introduction Introduction  UsesUses  ComponentsComponents  Difference between HTML and DHTMLDifference.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQuery Web Services A web service is a software system that supports interaction (requesting data,
Building Windows 8 Apps with HTML & JavaScript Jaime Rodriguez Principal
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Beautiful Sites and Apps Easy-to-build, Touch-First Interactivity Engaging Page Layouts Better Client/Server Data Transfer Powerful Local Data and Offline.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CSCE Chapter 5 (Links, Images, & Multimedia) CSCE General Applications Programming Benito Mendoza 1 By Benito Mendoza Department.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Adapting web pages for mobile devices Fredrik Andersson Hannes Nevalainen.
HTML, XHTML, and CSS Sixth Edition Chapter 1 Introduction to HTML, XHTML, and CSS.
JavaScript, Fourth Edition
Windows 8 Apps Guy Burstein Technical Evangelist, Microsoft
Adding Images Learning Web Design: Chapter 7. Using an Image Images have many purposed on a Web site Used as a static image To add illustration: ex. A.
Abigail morris.  Today I'm going to be explaining why the Internet relies on a number of protocols in order to function properly.  A protocol is simply.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
Use CSS to Implement a Reusable Design Selecting a Dreamweaver CSS Starter Layout is the easiest way to create a page with a CSS layout You can access.
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Web Development 101 Presented by John Valance
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
PERFORMANCE ENHANCEMENT IN ASP.NET By Hassan Tariq Session #1.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
Introduction to CSS. Why CSS? CSS Provides Efficiency in Design and Updates CSS relatively easy to use Can give you more flexibility and control Faster.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Introduction to HTML. _______________________________________________________________________________________________________________ 2 Outline Key issues.
EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)
Rich Internet Applications 3. Client JavaScript. Document Object Model (DOM) The DOM, is an interface that allows scripts or programs to access and manipulate.
Giorgio Sardo Technical Evangelist, Microsoft Corp blogs.msdn.com/Giorgio Session Code: WIA 403.
LESSON 15 – UNIT 0 ADAPTING YOUR WEB SITE FOR MOBILE DEVICES.
COMP2322 Lab 2 HTTP Steven Lee Jan. 29, HTTP Hypertext Transfer Protocol Web’s application layer protocol Client/server model – Client (browser):
Introduction to the World Wide Web & Internet CIS 101.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
Enhance Your Page Load Speed And Improve Traffic.
National College of Science & Information Technology.
Web Basics: HTML/CSS/JavaScript What are they?
50 Performance Tricks to Make your HTML5 apps and sites Faster
Chapter 1 Introduction to HTML.
Project 1 Introduction to HTML.
Building beautiful and interactive apps with HTML5 & CSS3
9/21/ :03 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
In-Depth Look at Internet Explorer 9
Web Development 101 Workshop
Presentation transcript:

Windows 8 Windows Core OS Services JavaScript (Chakra) C C++ C# VB Windows Store Apps Communication & Data Application Model Devices & Printing WinRT APIs Graphics & Media XAMLHTML / CSS HTML JavaScript C C++ C# VB Desktop Apps Win32. NET / SL Internet Explorer System Services View Model Controller Core

Windows 8 Windows Core OS Services JavaScript (Chakra) C C++ C# VB Windows Store Apps Communication & Data Application Model Devices & Printing WinRT APIs Graphics & Media XAMLHTML / CSS HTML JavaScript C C++ C# VB Desktop Apps Win32. NET / SL Internet Explorer System Services View Model Controller Core

Windows 8 Windows Core OS Services JavaScript (Chakra) C C++ C# VB Windows Store Apps Communication & Data Application Model Devices & Printing WinRT APIs Graphics & Media XAMLHTML / CSS HTML JavaScript C C++ C# VB Desktop Apps Win32. NET / SL Internet Explorer System Services View Model Controller Core

Windows 8 Windows Core OS Services JavaScript (Chakra) C C++ C# VB Windows Store Apps Communication & Data Application Model Devices & Printing WinRT APIs Graphics & Media XAMLHTML / CSS HTML JavaScript C C++ C# VB Desktop Apps Win32. NET / SL Internet Explorer System Services View Model Controller Core

You’ll leave with… Understanding of what makes a site/app fast. Specific things to improve your performance today.

30 0

20 0

How much do you know about performance?

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

Which is the fastest website?

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

Which is the slowest website?

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

YUI Total Size (k) Number Elements CSS Rules Image Files Script Lines (F) Script Libraries Site #1 3,6971,5041, ,768 Site #2 2,2781,1005, ,183 Site #3 1,0612,6731, ,643 Site #4 1,8124,2521, ,284 Site #5 1, ,902638,269 jQueryPrototypeExtJS Other Scriptaculous

What is web performance?

Core 1Core 2 Core 3Core 4 GPU

CPU Activity Initial Document Requested Waiting For Initial Document Processing Initial Document

CPU Activity Waiting For Sub-Downloads Processing Content

CPU Activity Waiting For XHR Processing Content (again) Page Displayed To Screen Page Finished Loading Page Updates Screen Processing Content

CPU Activity Elapsed Page Load Time (1.81 seconds)Time to Glass (1.14 seconds)CPU Time (1.39 seconds)Idle CPU Time (0.42 seconds)

CPU Activity Elapsed Page Load Time (1.81 seconds)Time to Glass (1.14 seconds)CPU Time (1.39 seconds)Idle CPU Time (0.42 seconds)

Where does the CPU time go?

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

NetworkingHTMLCSSCollectionsJavaScriptMarshallingDOMFormatting Block Building LayoutRendering

50 Performance Tricks

Six Principles to Remember 1)Quickly Respond to Network Requests 2)Minimize Bytes Downloaded 3)Efficiently Structure Markup 4)Optimize Media Usage 5)Write Fast JavaScript 6)Know What Your Application is Doing

Principle #1: Quickly Respond to Network Requests

Avoid 3xx Redirection Quickly Respond to Network Requests

Request GET / HTTP/1.1 Host:

Avoid 3xx Redirection Quickly Respond to Network Requests Response HTTP/ See Other Location: Request GET / HTTP/1.1 Host:

Avoid 3xx Redirection Quickly Respond to Network Requests 63% of top 1000 websites worldwide contain 3xx redirect

Avoid Meta Refresh Tag Quickly Respond to Network Requests

Avoid Meta Refresh Tag Quickly Respond to Network Requests 14% of worldwide URL’s contain meta-refresh

Minimize Server Time for Requests Quickly Respond to Network Requests

Use Content Distribution Networks (CDN’s) Quickly Respond to Network Requests

Maximize Concurrent Connections Quickly Respond to Network Requests

HTTP Response HTTP/ OK Content-Type: application/javascript Content-Length: Connection: close Reuse Connections Quickly Respond to Network Requests

HTTP Response HTTP/ OK Content-Type: application/javascript Content-Length: Connection: close Reuse Connections Quickly Respond to Network Requests

Know Your Servers Quickly Respond to Network Requests

Understand Your Network Timing Quickly Respond to Network Requests

Principle #2: Minimize Bytes Downloaded

Download Fewer Resources and Bytes Minimize Bytes Downloaded 777k average number of bytes downloaded

Download Fewer Resources and Bytes Minimize Bytes Downloaded

Request GET / HTTP/1.1 Accept: */* Accept-Language: en-us UA-CPU: x86 Accept-Encoding: gzip, deflate Host: Response HTTP/ OK Content-Length: 3479 Expires: -1 Date: Sun, 14 Mar :30:46 GMT Pragma: no-cache Content-Encoding: gzip GZIP Compress Network Traffic Minimize Bytes Downloaded

Request GET / HTTP/1.1 Accept: */* Accept-Language: en-us UA-CPU: x86 Accept-Encoding: gzip, deflate Host: Response HTTP/ OK Content-Length: 3479 Expires: -1 Date: Sun, 14 Mar :30:46 GMT Pragma: no-cache Content-Encoding: gzip GZIP Compress Network Traffic Minimize Bytes Downloaded

Request GET / HTTP/1.1 Accept: */* Accept-Language: en-us UA-CPU: x86 Accept-Encoding: gzip, deflate Host: Response HTTP/ OK Content-Length: 3479 Expires: -1 Date: Sun, 14 Mar :30:46 GMT Pragma: no-cache Content-Encoding: gzip GZIP Compress Network Traffic Minimize Bytes Downloaded

Persist App Resources Locally in Package Minimize Bytes Downloaded

Cache Dynamic Resources in App Cache Minimize Bytes Downloaded

v2 Cache Dynamic Resources in App Cache Minimize Bytes Downloaded

Request GET /images/banner.jpg HTTP/1.1 Host: Response HTTP/ OK Content-Type: image/jpeg Expires: Fri, 20 Apr :00:00 GMT Provide Cacheable Content Minimize Bytes Downloaded

Request GET /images/banner.jpg HTTP/1.1 Host: Response HTTP/ OK Content-Type: image/jpeg Expires: Fri, 20 Apr :00:00 GMT Provide Cacheable Content Minimize Bytes Downloaded

Request GET /images/banner.jpg HTTP/1.1 Host: If-Modified-Since: Sun, 10 Apr :30:46 GMT Response HTTP/ Not Modified Content-Type: image/jpeg Last-Modified: Sun, 1 Mar :30:46 GMT Send Conditional Requests Minimize Bytes Downloaded

Request GET /images/banner.jpg HTTP/1.1 Host: If-Modified-Since: Sun, 10 Apr :30:46 GMT Response HTTP/ Not Modified Content-Type: image/jpeg Last-Modified: Sun, 1 Mar :30:46 GMT Send Conditional Requests Minimize Bytes Downloaded

Request GET /images/banner.jpg HTTP/1.1 Host: If-Modified-Since: Sun, 10 Apr :30:46 GMT Response HTTP/ Not Modified Content-Type: image/jpeg Last-Modified: Sun, 1 Mar :30:46 GMT Send Conditional Requests Minimize Bytes Downloaded

jQuery Data Request jQuery.ajax({ url: url, dataType: 'json', data: data, success: callback }); Cached jQuery Data Request jQuery.ajax({ url: url, dataType: 'json', data: data, cache: true, success: callback }); Cache Data Requests Minimize Bytes Downloaded

jQuery Data Request jQuery.ajax({ url: url, dataType: 'json', data: data, success: callback }); Cached jQuery Data Request jQuery.ajax({ url: url, dataType: 'json', data: data, cache: true, success: callback }); Cache Data Requests Minimize Bytes Downloaded

Lower Case Title Case Careless Developer Standardize File Capitalization Convention Minimize Bytes Downloaded

Lower Case Title Case Careless Developer Standardize File Capitalization Convention Minimize Bytes Downloaded

Lower Case Title Case Careless Developer Standardize File Capitalization Convention Minimize Bytes Downloaded

Lower Case Title Case Careless Developer Standardize File Capitalization Convention Minimize Bytes Downloaded

Principle #3: Efficiently Structure Markup

Load Pages in Latest Browser Mode (HTML5) Efficiently Structure Markup

Page Meta Tag Use HTTP Header to Specify Legacy IE Modes Efficiently Structure Markup HTTP Header HTTP/ OK Date: Sun, 14 Mar :30:46 GMT X-UA-Compatible: IE=EmulateIE7

Page Meta Tag Use HTTP Header to Specify Legacy IE Modes Efficiently Structure Markup HTTP Header HTTP/ OK Date: Sun, 14 Mar :30:46 GMT X-UA-Compatible: IE=EmulateIE7

Page Meta Tag Use HTTP Header to Specify Legacy IE Modes Efficiently Structure Markup HTTP Header HTTP/ OK Date: Sun, 14 Mar :30:46 GMT X-UA-Compatible: IE=EmulateIE7

Link Style Sheets at Top of Page Efficiently Structure Markup Test …

Link Style Sheets at Top of Page Efficiently Structure Markup Test …

Test … Never Link Style Sheets at Bottom of Page Efficiently Structure Markup

Test … Never Link Style Sheets at Bottom of Page Efficiently Structure Markup

@import url(/stylesheets/two.css); MyHeading { color: red; font-family: 'New Century Schoolbook', serif; background: white; } Avoid for Hierarchical Styles Efficiently Structure Markup

@import url(/stylesheets/two.css); MyHeading { color: red; font-family: 'New Century Schoolbook', serif; background: white; } Avoid for Hierarchical Styles Efficiently Structure Markup

Test.item { color:#009900;} MyItem Avoid Embedded and Inline Styles Efficiently Structure Markup

Test.item { color:#009900;} MyItem Avoid Embedded and Inline Styles Efficiently Structure Markup

/* These styles are for the home page. */ HomePage { color: red; } /* These styles are for the content page. */ ContentPage { color: green; } Only Include Necessary Styles Efficiently Structure Markup

/* These styles are for the home page. */ HomePage { color: red; } /* These styles are for the content page. */ ContentPage { color: green; } Only Include Necessary Styles Efficiently Structure Markup

/* These styles are for the home page. */ HomePage { color: red; } /* These styles are for the content page. */ ContentPage { color: green; } Only Include Necessary Styles Efficiently Structure Markup

Always Link JavaScript at End of File Efficiently Structure Markup

Test … Avoid Linking JavaScript In Head Efficiently Structure Markup

Test … Avoid Linking JavaScript In Head Efficiently Structure Markup

function helloWorld() { alert('Hello World!') ; } … Avoid Inline JavaScript Efficiently Structure Markup

function helloWorld() { alert('Hello World!') ; } … Avoid Inline JavaScript Efficiently Structure Markup

Test … Use the Defer Tag When Head Only Option Efficiently Structure Markup

Test … Use the Defer Tag When Head Only Option Efficiently Structure Markup

Test … Asynchronously Download Script Efficiently Structure Markup

Test … Asynchronously Download Script Efficiently Structure Markup

Test … Remove Duplicate Code Efficiently Structure Markup

Test … Remove Duplicate Code Efficiently Structure Markup

52% of the pages on the web have duplicate code

… Standardize on a Single Framework Efficiently Structure Markup

… Don’t Include Script To Be Cool Efficiently Structure Markup

Principle #4: Optimize Media Usage

Minimize Number of Images Optimize Media Usage

58 average number of media resources on the top 100,000 web sites

Avoid Death by 1,000 Images Optimize Media Usage

Use Image Sprites Optimize Media Usage 240px 40px Scenario #1 – Multiple FilesScenario #2 - Image Sprite 40px 6 Images 6 Connections 96k Download 1 Image 1 Connection 21k Download 40px

Create Your Sprites by Hand Optimize Media Usage 700px 289px

Create Your Sprites by Hand Optimize Media Usage 700px 289px

Image Formats: PNG, JPEG, JPEG-XR Optimize Media Usage PNG (Default) Website Elements, Logos JPEG Photographs JPEG-XR High Resolution Photographs Don’t Get Distracted GIF, TIFF, BMP, WebP, etc.

Test … … Use Native Image Resolutions Optimize Media Usage

Test … … Use Native Image Resolutions Optimize Media Usage

Test … … Use Native Image Resolutions Optimize Media Usage

Replace Images with CSS3 Gradients Optimize Media Usage

Replace Images with CSS3 Border Radius Optimize Media Usage

Leverage CSS3 Transforms Optimize Media Usage -ms-transform: translate(75px, 100px) scaleY(.75) skewY(10deg); -webkit-transform: translate(75px, 100px) scaleY(.75) skewY(10deg); -moz-transform: translate(75px, 100px) scaleY(.75) skewY(10deg); -o-transform: translate(75px, 100px) scaleY(.75) skewY(10deg); ElementRotateSkewMove

Test <img src= "data:image/png;base64 iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblA" alt="Red dot" /> Use DataURI’s for Small Single View Images Optimize Media Usage

Test <img src= "data:image/png;base64 iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblA" alt="Red dot" /> Use DataURI’s for Small Single View Images Optimize Media Usage

Test <img src= "data:image/png;base64 iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblA" alt="Red dot" /> Use DataURI’s for Small Single View Images Optimize Media Usage

Test <img src= "data:image/png;base64 iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblA" alt="Red dot" /> Use DataURI’s for Small Single View Images Optimize Media Usage

Avoid Complex SVG Paths Optimize Media Usage

Video: User Preview Images Optimize Media Usage

Minimize Media Plugin Usage Optimize Media Usage

Proactively Download Future Media Optimize Media Usage

Principle #5: Write Fast JavaScript

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

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 …… … 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);

Minify Your JavaScript Write Fast Loading JavaScript

Initial (66 Characters) function Sum(number1, number2) { return (number1 + number2); } Minify Your JavaScript Write Fast Loading JavaScript

Initial (66 Characters) function Sum(number1, number2) { return (number1 + number2); } Characters Removed (54 Characters) function Sum(number1,number2){return number1+number2;} Minify Your JavaScript Write Fast Loading JavaScript

Initial (66 Characters) function Sum(number1, number2) { return (number1 + number2); } Characters Removed (54 Characters) function Sum(number1,number2){return number1+number2;} Compacted (30 Characters) function Sum(a,b){return a+b;} Minify Your JavaScript Write Fast Loading JavaScript

Initialize JavaScript on Demand Write Fast Loading JavaScript var userTileScriptsLoaded = false; function CustomizeUserTile() { if (userTileScriptsLoaded == false) { var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'upload.js'; head.appendChild(script); }

Initialize JavaScript on Demand Write Fast Loading JavaScript var userTileScriptsLoaded = false; function CustomizeUserTile() { if (userTileScriptsLoaded == false) { var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'upload.js'; head.appendChild(script); }

Initialize JavaScript on Demand Write Fast Loading JavaScript var userTileScriptsLoaded = false; function CustomizeUserTile() { if (userTileScriptsLoaded == false) { var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'upload.js'; head.appendChild(script); }

Initialize JavaScript on Demand Write Fast Loading JavaScript var userTileScriptsLoaded = false; function CustomizeUserTile() { if (userTileScriptsLoaded == false) { var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'upload.js'; head.appendChild(script); }

Initialize JavaScript on Demand Write Fast Loading JavaScript var userTileScriptsLoaded = false; function CustomizeUserTile() { if (userTileScriptsLoaded == false) { var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'upload.js'; head.appendChild(script); }

Minimize DOM Interactions Use DOM Efficiently function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }

Minimize DOM Interactions Use DOM Efficiently function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }

Minimize DOM Interactions Use DOM Efficiently function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }

function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; } Minimize DOM Interactions Use DOM Efficiently

function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }

Minimize DOM Interactions Use DOM Efficiently function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }

Minimize DOM Interactions Use DOM Efficiently function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }

Minimize DOM Interactions Use DOM Efficiently function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }

Minimize DOM Interactions Use DOM Efficiently function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; } 15 lookups

function LoopChildren(elm) { var node = elm.firstChild; while (node != null) { node = node.nextSibling; } Built in DOM Methods Always More Efficient Use DOM Efficiently

function LoopChildren(elm) { var node = elm.firstChild; while (node != null) { node = node.nextSibling; } Built in DOM Methods Always More Efficient Use DOM Efficiently

function LoopChildren(elm) { var node = elm.firstChild; while (node != null) { node = node.nextSibling; } Built in DOM Methods Always More Efficient Use DOM Efficiently

function doValidation() { var reqs = document.querySelectorAll(".required"); var missingRequiredField = false; for (var i = 0; i < reqs.length; i++) { if (reqs[i].value == "") missingRequiredField = true; } Use Selectors API for Collection Access Use DOM Efficiently

function doValidation() { var reqs = document.querySelectorAll(".required"); var missingRequiredField = false; for (var i = 0; i < reqs.length; i++) { if (reqs[i].value == "") missingRequiredField = true; } Use Selectors API for Collection Access Use DOM Efficiently

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

Maintain a Small and Healthy DOM Use DOM Efficiently DocumentHTMLBody Element

JSON Always Faster than XML for Data XML Representation example glossary S Markup Language SGML ISO 8879:1986 meta-markup language

Native JSON Methods var jsObjStringParsed = JSON.parse(jsObjString); var jsObjStringBack = JSON.stringify(jsObjStringParsed); Use Native JSON Methods Write Fast JavaScript

Use Regular Expressions Sparingly Write Fast JavaScript var foo = ^(?:\$\s*)?(?:(?:\d{0,3}(?:[, ]\d{0,3})*(?:\s*\$)\\;

Principle #6: Know What Your Application is Doing

setTimeout setTimeout(callback, ms); setInterval var test = setInterval(callback, ms); clearInterval(test); Understand JavaScript Timers Know What Your Application is Doing nnnnnn

Combine Application Timers Know What Your Application is Doing

Align Timers to the Display Frame (16.7) Know What Your Application is Doing setInterval(renderLoop, 16.7); setInterval(renderLoop, 33.4); 16.7

Use requestAnimationFrame for Animations Know What Your Application is Doing window.requestAnimationFrame(renderLoop); 16.7

Know When Your App is Visible Know What Your Application is Doing Page Visibility API document.hidden (property) Visibilitychange (event)

Six Principles to Remember 1)Quickly Respond to Network Requests 2)Minimize Bytes Downloaded 3)Efficiently Structure Markup 4)Optimize Media Usage 5)Write Fast JavaScript 6)Know What Your Application is Doing

Core 1Core 2 Core 3Core 4 GPU

?

