SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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.
 

Semelhante a 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 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
 
Lessons
LessonsLessons
Lessons
 
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
 

Último

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Último (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

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