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

Slides:



Advertisements
Similar presentations
Web 2.0 Programming 1 © Tongji University, Computer Science and Technology. Web Web Programming Technology 2012.
Advertisements

CS193H: High Performance Web Sites Lecture 4: Class Projects Steve Souders Google
CS193H: High Performance Web Sites Lecture 20: Vol 2 – Don't Scatter Inline Scripts Steve Souders Google
Steve Souders Even Faster Web Sites best practices for faster pages Disclaimer: This content does not necessarily.
CS193H: High Performance Web Sites Lecture 19: Vol 2 – Load Scripts Without Blocking Steve Souders Google
CS193H: High Performance Web Sites Lecture 10: Rule 6 – Put Scripts at the Bottom Steve Souders Google
Widget Summit: Advanced JavaScript Joseph Smarr Plaxo, Inc. October 16, 2007.
Web Toolkit Julie George & Ronald Lopez 1. Requirements  Java SDK version 1.5 or later  Apache Ant is also necessary to run command line arguments 
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
CHAPTER 15 WEBPAGE OPTIMIZATION. LEARNING OBJECTIVES How to test your web-page performance How browser and server interactions impact performance What.
JQuery & SharePoint San Antonio Users Group – September Meeting September 22, 2009 Microsoft SharePoint Server.
DATABASE APPLICATION DEVELOPMENT SAK 3408 The Web and DBMS.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Mark Phillip markphillip.com 200s, 304s, Expires Headers, HTTP Compression, And You.
1 Subspace: Secure Cross Domain Communication for Web Mashups Collin Jackson and Helen J. Wang Mamadou H. Diallo.
Performance, SEO, Accessibility Ivan Zhekov Telerik Corporation
Presented by…. Group 2 1. Programming language 2Introduction.
DHTML - Introduction Introduction to DHTML, the DOM, JS review.
May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Build Great Web Application 'Fast and Easy'
Dynamic Web Pages (Flash, JavaScript)
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Chapter 19: Adding JavaScript
DOM and JavaScript Aryo Pinandito.
CSCE Chapter 5 (Links, Images, & Multimedia) CSCE General Applications Programming Benito Mendoza 1 By Benito Mendoza Department.
JQUERY | INTRODUCTION. jQuery  Open source JavaScript library  Simplifies the interactions between  HTML document, or the Document Object Model (DOM),
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.
1 Approaches for Asynchronous Communication in Web Applications Stefan Potthast and Mike Rowe.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Cross Site Integration “mashups” cross site scripting.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
Don't Let Third Parties Slow You Down Arvind Jain, Michael Kleber Google.
Building Rich Web Applications with Ajax Linda Dailey Paulson IEEE – Computer, October 05 (Vol.38, No.10) Presented by Jingming Zhang.
Web Design (1) Terminology. Coding ‘languages’ (1) HTML - Hypertext Markup Language - describes the content of a web page CSS - Cascading Style Sheets.
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.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
PERFORMANCE ENHANCEMENT IN ASP.NET By Hassan Tariq Session #1.
Chapter 4 Applets Cop Why Applets? WWW makes huge information available to anyone with web browser. Web server send web pages and images to your.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
Safe browsing - is an ad-blocker extension enough? AIMILIOS TSOUVELEKAKIS IT-DI-CSO IT LIGHTNING TALK – 12/
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Web Technologies Lecture 7 Synchronous vs. asynchronous.
Restricted © Siemens AG All rights reserved A Developer’s Insights Into Performance Optimizations for Mobile Web Apps CT DC AA EM LP2 | June 2015.
Trevor Jim Nikhil Swamy Michael Hicks Defeating Script Injection Attacks with Browser-Enforced Embedded Policies Jason FroehlichSeptember 24, 2008.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
LESSON 15 – UNIT 0 ADAPTING YOUR WEB SITE FOR MOBILE DEVICES.
Node.Js 1. 2 Contents About Node.Js Web requirement latest trends Introduction Simple web server creation in Node.Js Dynamic Web pages Dynamic web page.
 AJAX technology  Rich User Experience  Characteristics  Real live examples  JavaScript and AJAX  Web application workflow model – synchronous vs.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
IN THIS LESSON WE WILL REVIEW THE STRUCTURE OF THE INTERNET AND HOW BROWSERS ASSEMBLE WEBSITES BASED ON INSTRUCTIONS THEY RECEIVE FROM SERVERS. Internet.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
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.
Google Maps API v3: Built First for Mobile Susannah Raub Google June 24, 2010.
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
BTEC NCF Dip in Comp - Unit 15 Website Development Lesson 05 – Website Performance Mr C Johnston.
Application with Cross-Platform GUI
AJAX.
Dynamic Web Pages (Flash, JavaScript)
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
Tips for Website Speed Optimization
Introduction to DHTML, the DOM, JS review
Web Development 101 Workshop
Yale Digital Conference 2019
Presentation transcript:

Building Fast 3rd-Party Webapps O'Reilly Velocity Web Performance and Operations Conference 24 June Lessons learned from the Meebo Bar Martin Hunt and Marcus Westin

The Meebo Bar A customizable site bar with real-time social interaction

Meebo Bar, a 3rd Party Webapp How do we make it run fast? Loads on every page Interacts with the page JavaScript, CSS, Images & HTML How do we make it respectful?

3rd Party Webapps The Challenge Do Load lots of features Load features fast Without Blocking rendering or onload Affecting User Experience How?

3rd Party Webapps: How? How to initialize a webapp Asynchronous & non-blocking o Defer Execution Minimize impact when loading CSS and Images Crush, Combine, Avoid Perceived Performance Testing and psychology ToolsTechniques

Meebo Bar embed code executes in ~10ms o no blocking network requests o no dependency on our server less than 1200 characters gzips to about 700 bytes embedded directly in page HTML or JS executes even if our servers are not reachable

Initializing 3rd Party Webapps Script Tag append a script tag using JavaScript to the head of the document Commonly accepted, but... Inline JS easy for publishers to add blocks the page in all browsers XMLHttpRequests Asynchronous, non- blocking same-domain in most browsers Iframe load an HTML file in an iframe Requires HTML file on the hosting site

Accepted script loading code var head = document.getElementsByTagName('head')[0], el = document.createElement('script'); el.src = " head.appendChild(el); good: cross domain (we're 3rd party content!) good: doesn't block network traffic

Don't block the page! Script Tag Append can block scripts in Firefox! blocks other scripts in Firefox scripts execute in order all scripts on the page block until the appended script downloads and executes (defer attribute supported in FF3.5+) blocks onload event in all browsers are there alternative nonblocking methods?

Iframed JS 1.Iframes load HTML, not JS 2.Cross iframe communication is same-domain only (non-HTML5 browsers) 3.Window onload event fires after all iframes load

Iframed JS - the solution var iframe = document.createElement('iframe'), doc = iframe.contentWindow.document; doc.open().write(' ') doc.close()

More About Iframes iframe creation overhead? Creating one DOM node o Chrome < 1ms o Firefox, Safari ~1ms o IE ~5ms Sandboxed JavaScript 3rd party code will not break webpage code Webpage code will not break 3rd party code! for (var i in x) {}

Defer Execution

Lots of stuff happens in a browser while loading a page Then, relatively little happens... Take advantage of this!

Defer Execution Example In-page sharing

Naive implementation function makeSharable(elements) { for (var i=0; i < elements.length; i++) { var element = elements[i]; var metadata = lookupMetadata(element); element.on('mousedown', startDrag, metadata); } function lookupMetadata(el) { do { inspectElement(el) } while(el = el.parentNode) } O(N) O(M) O(N*M)

Deferred implementation function initShare() { document.on('mousedown', function(e) { var el = e.target || e.srcElement if (!el.getAttribute('meeboSharable')) { return; } var metadata = lookupMetadata(el); document.on('mousemove', handleDrag, metadata); document.on('mouseup', stopDrag, metadata); }); } O(1) Page finishes loading

Modularize & Lazy Load users don't need all features immediately 1-1 Messaging connect to all the IM networks Broadcasting publishers send new content to users Social Networking receive updates about your friends' activities Sharing share site content to Facebook, Twitter, Buzz, and other sites Site Widgets site-specific widgets: videos, menus, navigation tools, etc.

Modularize & Lazy Load Also applies to images and CSS! Careful: Loading images can create a lot of HTTP requests

Loading Images Spriting and preloading is hard Still creates additional HTTP requests Difficult to automate Embed images into CSS instead DataURIs and MHTML files Details on the Meebo devblog (

Use Vector Graphics Vector graphics are supported in all major browsers Firefox 3+ Opera 9.5+ IE 6+ Safari 3+ Chrome

Without images With images

Tools - use them! Preprocess if possible if multiple clients are doing the exact same task, run it on the server generate content offline Compilers Closure Compiler Profilers DynaTrace (IE) Speed tracer (Chrome) Firebug (FF) Safari 5/WebKit

Perceived Performance Quick loading content on a slow page appears to be the cause of the slow page Delaying interface drawing can look slow or broken Do not forget: Even asynchronous loading slows down a page. Keep payloads minimal and always monitor performance!

Questions? Highlights Always compress and minify content Use an IFrame to load the main script payload Defer execution until needed Defer content download until needed Remove HTTP requests by combining content o Embed images into CSS o Use vector graphics