SlideShare a Scribd company logo
1 of 31
Download to read offline
Building Fast 3rd-Party Webapps
   Lessons learned from the Meebo Bar



                     Marcus Westin
                follow me @marcuswestin



    (a replay from O'Reilly Velocity conference 24 June 2010)


             On Twitter:
      @marcuswestin and @mghunt
The Meebo Bar
A customizable site bar with real-time social interaction
Meebo Bar, a 3rd Party Webapp
     JavaScript, CSS, Images & HTML


         Interacts with the page
         Loads on every page


   How do we make it run fast?
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?
Meebo Bar embed code
executes in ~10ms
   no blocking network requests
   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
Inline JS <script src="">    Iframe <iframe src="">
easy for publishers to add   load an HTML file in an iframe
blocks the page in all       Requires HTML file on the
browsers                     hosting site


XMLHttpRequests              Script Tag
Asynchronous, non-           append a script tag using
blocking                     JavaScript to the head of
same-domain in most          the document
browsers                     Commonly accepted,
                             but...
Accepted script loading code
var head = document.getElementsByTagName('head')[0],
el = document.createElement('script');
el.src = "http://www.myDom.ain/myScript.js"; 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(
  '<script>function loadJS() { ... }</script>' +
  '<body onload="loadJS()">')
doc.close()
More About Iframes
iframe creation overhead?

  Creating one DOM node
      Chrome < 1ms
      Firefox, Safari ~1ms
      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
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
Defer Execution Example
    In-page sharing
Defer Execution Example
    In-page sharing
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);
                                                    O(N)
  }
}
function lookupMetadata(el) {
  do {
    inspectElement(el)
  } while(el = el.parentNode)                       O(M)
}




                                     O(N*M)
Deferred implementation

function initShare() {
  document.on('mousedown', function(e) {                  O(1)
     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);
  });
}




                                 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,
     Site Widgets               and other sites
   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 (http://mee.
bo/cssimages)
Use Vector Graphics

Vector graphics are supported
in all major browsers

   Firefox 3+
   Opera 9.5+
   IE 6+
   Safari 3+
   Chrome
With images




Without images
Tools   Techniques
        How to initialize a webapp
        Asynchronous & non-blocking

        Defer Execution
        Minimize impact when loading
        CSS and Images
        Crush, Combine, Avoid
        Perceived Performance
        Testing and psychology
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!
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
   Embed images into CSS
   Use vector graphics



   Questions? (+ ping me on twitter)
                 @marcuswestin
We need better tools for measuring
webapp performance!

Need to accurately determine the
impact of a webapp on a website
Browser Cache
New visitors don't have anything cached!

Browsers can automatically clear cache

Yahoo! YUI study:
  40-60% of Yahoo!'s users have an empty cache
  20% of all page views have an empty cache

More Related Content

What's hot

DotNed Umbraco Presentation
DotNed Umbraco PresentationDotNed Umbraco Presentation
DotNed Umbraco PresentationRoel
 
Web Front End Performance
Web Front End PerformanceWeb Front End Performance
Web Front End PerformanceChris Love
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesVitaly Friedman
 
Introduction to WordPress Class 1
Introduction to WordPress Class 1Introduction to WordPress Class 1
Introduction to WordPress Class 1Adrian Mikeliunas
 
jQuery Conference Toronto
jQuery Conference TorontojQuery Conference Toronto
jQuery Conference Torontodmethvin
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1James Pearce
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can buildMonika Piotrowicz
 
Implementing a Responsive Image Strategy
Implementing a Responsive Image StrategyImplementing a Responsive Image Strategy
Implementing a Responsive Image StrategyChris Love
 
Technical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 editionTechnical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 editionOtto Kekäläinen
 
EdTechJoker Spring 2020 - Lecture 4 - HTML
EdTechJoker Spring 2020 - Lecture 4 - HTMLEdTechJoker Spring 2020 - Lecture 4 - HTML
EdTechJoker Spring 2020 - Lecture 4 - HTMLBryan Ollendyke
 
Real World Web Standards
Real World Web StandardsReal World Web Standards
Real World Web Standardsgleddy
 
8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress website8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress websiteSiteGround.com
 
The Future Is Here: It's Just Not Evenly Distributed
The Future Is Here: It's Just Not Evenly DistributedThe Future Is Here: It's Just Not Evenly Distributed
The Future Is Here: It's Just Not Evenly DistributedMartin Hamilton
 
Basic Wordpress Session
Basic Wordpress SessionBasic Wordpress Session
Basic Wordpress SessionVipul Garg
 
HTML / CSS / JS Web basics
HTML / CSS / JS Web basicsHTML / CSS / JS Web basics
HTML / CSS / JS Web basicsbtopro
 
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
 

What's hot (20)

DotNed Umbraco Presentation
DotNed Umbraco PresentationDotNed Umbraco Presentation
DotNed Umbraco Presentation
 
Intro to Web Development
Intro to Web DevelopmentIntro to Web Development
Intro to Web Development
 
Web Front End Performance
Web Front End PerformanceWeb Front End Performance
Web Front End Performance
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
 
Introduction to WordPress Class 1
Introduction to WordPress Class 1Introduction to WordPress Class 1
Introduction to WordPress Class 1
 
jQuery Conference Toronto
jQuery Conference TorontojQuery Conference Toronto
jQuery Conference Toronto
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can build
 
Wordpress for Dummies
Wordpress for DummiesWordpress for Dummies
Wordpress for Dummies
 
Implementing a Responsive Image Strategy
Implementing a Responsive Image StrategyImplementing a Responsive Image Strategy
Implementing a Responsive Image Strategy
 
Technical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 editionTechnical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 edition
 
Browser Security
Browser SecurityBrowser Security
Browser Security
 
EdTechJoker Spring 2020 - Lecture 4 - HTML
EdTechJoker Spring 2020 - Lecture 4 - HTMLEdTechJoker Spring 2020 - Lecture 4 - HTML
EdTechJoker Spring 2020 - Lecture 4 - HTML
 
Real World Web Standards
Real World Web StandardsReal World Web Standards
Real World Web Standards
 
8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress website8 Ways to Hack a WordPress website
8 Ways to Hack a WordPress website
 
The Future Is Here: It's Just Not Evenly Distributed
The Future Is Here: It's Just Not Evenly DistributedThe Future Is Here: It's Just Not Evenly Distributed
The Future Is Here: It's Just Not Evenly Distributed
 
Basic Wordpress Session
Basic Wordpress SessionBasic Wordpress Session
Basic Wordpress Session
 
Joomla
JoomlaJoomla
Joomla
 
HTML / CSS / JS Web basics
HTML / CSS / JS Web basicsHTML / CSS / JS Web basics
HTML / CSS / JS Web basics
 
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
 

Similar to Meebo performance ny_web_performance

Building fast webapps, fast - Velocity 2010
Building fast webapps, fast - Velocity 2010Building fast webapps, fast - Velocity 2010
Building fast webapps, fast - Velocity 2010marcuswestin
 
7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websitesoazabir
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 
Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)Clarence Ngoh
 
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
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-airbrucelawson
 
Web II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side developmentWeb II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side developmentRandy Connolly
 
Skill Session - Web Multi Device
Skill Session - Web Multi DeviceSkill Session - Web Multi Device
Skill Session - Web Multi Devicefilirom1
 
Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Atos_Worldline
 
Lessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX ExperiencesLessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX Experiencesgoodfriday
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkSt. Petersburg College
 
Faster Frontends
Faster FrontendsFaster Frontends
Faster FrontendsAndy Davies
 
Bringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersBringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersCorey Clark, Ph.D.
 

Similar to Meebo performance ny_web_performance (20)

Building fast webapps, fast - Velocity 2010
Building fast webapps, fast - Velocity 2010Building fast webapps, fast - Velocity 2010
Building fast webapps, fast - Velocity 2010
 
7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)
 
Html5
Html5Html5
Html5
 
HTML5
HTML5HTML5
HTML5
 
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
Html5Html5
Html5
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-air
 
Web II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side developmentWeb II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side development
 
Skill Session - Web Multi Device
Skill Session - Web Multi DeviceSkill Session - Web Multi Device
Skill Session - Web Multi Device
 
Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...
 
Lessons
LessonsLessons
Lessons
 
Lessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX ExperiencesLessons from the Trenches: Engineering Great AJAX Experiences
Lessons from the Trenches: Engineering Great AJAX Experiences
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
 
Webpack
Webpack Webpack
Webpack
 
Faster Frontends
Faster FrontendsFaster Frontends
Faster Frontends
 
Bringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersBringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkers
 

Recently uploaded

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 

Recently uploaded (20)

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 

Meebo performance ny_web_performance

  • 1. Building Fast 3rd-Party Webapps Lessons learned from the Meebo Bar Marcus Westin follow me @marcuswestin (a replay from O'Reilly Velocity conference 24 June 2010) On Twitter: @marcuswestin and @mghunt
  • 2. The Meebo Bar A customizable site bar with real-time social interaction
  • 3. Meebo Bar, a 3rd Party Webapp JavaScript, CSS, Images & HTML Interacts with the page Loads on every page How do we make it run fast? How do we make it respectful?
  • 4. 3rd Party Webapps The Challenge Do Load lots of features Load features fast Without Blocking rendering or onload Affecting User Experience How?
  • 5. Meebo Bar embed code executes in ~10ms no blocking network requests 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
  • 6. Initializing 3rd Party Webapps Inline JS <script src=""> Iframe <iframe src=""> easy for publishers to add load an HTML file in an iframe blocks the page in all Requires HTML file on the browsers hosting site XMLHttpRequests Script Tag Asynchronous, non- append a script tag using blocking JavaScript to the head of same-domain in most the document browsers Commonly accepted, but...
  • 7. Accepted script loading code var head = document.getElementsByTagName('head')[0], el = document.createElement('script'); el.src = "http://www.myDom.ain/myScript.js"; head.appendChild(el); good: cross domain (we're 3rd party content!) good: doesn't block network traffic
  • 8. 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?
  • 9. 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
  • 10. Iframed JS - the solution var iframe = document.createElement('iframe'), doc = iframe.contentWindow.document; doc.open().write( '<script>function loadJS() { ... }</script>' + '<body onload="loadJS()">') doc.close()
  • 11. More About Iframes iframe creation overhead? Creating one DOM node Chrome < 1ms Firefox, Safari ~1ms 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) {}
  • 13. Defer Execution Lots of stuff happens in a browser while loading a page Then, relatively little happens... Take advantage of this!
  • 14. Defer Execution Example In-page sharing
  • 15. Defer Execution Example In-page sharing
  • 16. Defer Execution Example In-page sharing
  • 17. Defer Execution Example In-page sharing
  • 18. 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); O(N) } } function lookupMetadata(el) { do { inspectElement(el) } while(el = el.parentNode) O(M) } O(N*M)
  • 19. Deferred implementation function initShare() { document.on('mousedown', function(e) { O(1) 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); }); } Page finishes loading
  • 20. 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, Site Widgets and other sites site-specific widgets: videos, menus, navigation tools, etc.
  • 21. Modularize & Lazy Load Also applies to images and CSS! Careful: Loading images can create a lot of HTTP requests
  • 22. 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 (http://mee. bo/cssimages)
  • 23. Use Vector Graphics Vector graphics are supported in all major browsers Firefox 3+ Opera 9.5+ IE 6+ Safari 3+ Chrome
  • 25. Tools Techniques How to initialize a webapp Asynchronous & non-blocking Defer Execution Minimize impact when loading CSS and Images Crush, Combine, Avoid Perceived Performance Testing and psychology
  • 26. 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!
  • 27. 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 Embed images into CSS Use vector graphics Questions? (+ ping me on twitter) @marcuswestin
  • 28.
  • 29.
  • 30. We need better tools for measuring webapp performance! Need to accurately determine the impact of a webapp on a website
  • 31. Browser Cache New visitors don't have anything cached! Browsers can automatically clear cache Yahoo! YUI study: 40-60% of Yahoo!'s users have an empty cache 20% of all page views have an empty cache