• Save
New Perspectives on Performance
Upcoming SlideShare
Loading in...5
×
 

New Perspectives on Performance

on

  • 2,774 views

This is the presentation I gave on June 28 2012 at the jQuery conference in San Francisco

This is the presentation I gave on June 28 2012 at the jQuery conference in San Francisco

Statistics

Views

Total Views
2,774
Views on SlideShare
2,416
Embed Views
358

Actions

Likes
1
Downloads
0
Comments
0

6 Embeds 358

https://app.codegrid.net 270
http://eventifier.co 59
http://lanyrd.com 18
https://staging-codegrid.herokuapp.com 9
http://localhost 1
http://eventsp2.wordpress.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • The only obstacle between you and a couple of cold beers\nI know it’s been a long day of complex material\nDon’t worry, timed to about 25 minutes. As mentally challenging as Dora the Explorer\nBefore I get started I’d like to get to know you a little better\nBy show of hands, who here has ever received this simple request\n
  • So many of you have heard this. The rest will down the line. \nSuch a simple question but so hard to answer correctly\nThrough this presentation I’d like to give you some tools to deal with it\nIdeas about how to approach the problem\nAnd some tips to help you identify the issues\nFirst, imagine this scenario\n
  • \nJust asking for better performance is silly. Engineers are not magicians.\nAcceleration, top speed, handling in corners\nYou could call these the pillars of a race car’s performance\n
  • In my experience, these are the three attributes that define a web page’s performance\nI will briefly go over each of them\n
  • Now, I realize you want to get right down to business. \nStart fixing stuff, start improving code.\nDon’t.\nThere’s a couple of really important things that need to be taken care of\nFirst you need to establish a base line\n
  • Measurable: you can express it in a number. time or operations\nRepeatable: these numbers don’t vary wildly between tests\nif your performance varies a lot, you don't have performance issues, you have a bug.\nStable: It’s safe to make changes because of automated testing\nAnd then: gather data on as many different platforms as possible\nThis data is your baseline.\n
  • Don’t climb the tree for a coconut when there’s a banana right in front of you.\nUnless you really like coconuts.\nOr climbing.\n
  • Simply said: how long does it take to look good?\n\n
  • I know this is a cop-out but there's just too much good stuff in there.\nIt really is required reading.\nI do have some stuff to add\n
  • Yahoo’s YSlow, or Google’s PageSpeed are tools that analyze your web page.\nVery useful tools in determining the low hanging fruit I was talking about earlier.\nBe careful though, because they also point out coconuts. \nBefore you know it you’re climbing a tree.\n\n
  • Brace yourself. Code is coming.\n
  • Google will save all the events and average the data.\nSee how long your average user takes.\nInclude this in your baseline.\n
  • Simply said: 256-color PNG's with Alpha channel.\nDepending on how crazy your graphic designer is this can save 100s of KB\n
  • Mostly dependent on what scripts are loaded and run\nFor jQuery projects, much of this will be in a $.ready() handler.\n
  • For this sequel they really pulled out an all-star cast and it's just as gripping as the first one.\nI hear he's working on "Faster Web sites Strike Back"\n\n\n
  • \n
  • \n
  • Initialize on first click\nCheck out Doug’s presentation tomorrow on contextual jquery\n
  • \n
  • \n
  • In my experience the hardest to do right\nThe hardest to get significant results\nI can think of only one low-hanging fruit: repeating events\n
  • Some events fire once in a while, like click events, or even mouse hover\nOthers fire a lot like a keydown event in an input\nOthers still, fire all the time\nThe last 2 categories benefit a lot from either throttling or debouncing\nThrottling: once every x milliseconds, useful for drag or resizing\nDebouncing: once before/after a series, useful for keyboard\n\n
  • \n
  • \n
  • \n
  • Responsiveness is quite easy to fake\nAll you have to do is give immediate visual feedback before doing something heavy\nSpinners, progress bars, animations, anything to show that something is happening.\n\n
  • These 3 pillars are all different aspects of a web page’s performance but there is one thing that binds them:\nThey are from the user’s perspective\nBut there are other perspectives, like the business perspective. \nThere could be money involved\n
  • Improving performance is a time-consuming iterative process\nLot’s of trial and error and testing and comparing\nThere is a lot to lose and little to gain. \nThe most important gain is user happiness\nBut there are other ways to improve that,\nPerformance optimizations are relatively invisible\n
  • I’ve seen performance improvements that took one man 2 days to write\nand caused bugs that took weeks to fix in total\nunit tests will only catch so much. \nand don’t forget about maintainability. the better it performs the least flexible it probably is.\nI realize this may all sound blasphemous. Didn’t I just recommend books by famous yahoo & google devs?\nI did, and I stand by that.\n\n\n
  • They are the cream of the crop devs\nworking on projects where every ms and every kb is multiplied by millions and millions of users\nNo wonder they care so much about it\nMe? I'm more this guy\n
  • \nDoesn’t mean I can’t learn from them. Just need to weigh costs and benefits of their recommendations\nThe race car’s goal is not to drive fast but to win races.\nOur websites have goals as well. Provide info, user perform task, sometimes not clear.\nWebsite’s performance measured in how well it achieves those goals\nIt's about our performance, how well are we doing our job.\nAre we building web sites the world needs. Or are we just making them fast?\n
  • \n
  • \n

New Perspectives on Performance New Perspectives on Performance Presentation Transcript

  • NEW PERSPECTIVESON PERFORMANCE @mennovanslooten jQuery San Francisco 2012
  • HI, I’M MENNO•I live in The Netherlands•I make websites for http://www.aanzee.nl
  • Can you improve theperformance of this page?
  • A RACE CAR DRIVER
  • PILLARS OF PERFORMANCE• Visibility• Interactivity• Responsiveness
  • Before you start optimizing...
  • ESTABLISH A BASELINE• Measurable• Repeatable• Stable
  • Tip: Always focus first on low-hanging fruit
  • PILLAR 1: VISIBILITYGoing from about:blank to a styled web page
  • PILLAR 1: VISIBILITY• Read High Performance Web Sites by Steve Souders
  • PILLAR 1: VISIBILITY• Install Firebug and YSlow• Do whatever YSlow tells you (if you can do it in a day)• Don’t worry too much about the rest
  • Tip: Crowdsource your measurements with Google Analytics
  • <html> <head> <script> __START__ = new Date; </script>$.ready(function() { var time = new Date - __START__; _gaq.push( _trackEvent, performance, dom_ready, , time, true );}
  • Tip: 8-bit PNG’s with alpha: http://www.8bitalpha.com/
  • PILLAR 2: INTERACTIVITYGoing from visible and styled to fully clickable
  • PILLAR 2: INTERACTIVITY• Read Even Faster Web Sites by Steve Souders et al.
  • Tip: profile your $.ready()
  • // Don’t do this:$.ready(function() { whatever_happens(); here();}// to this:$.ready(function() { console.profile(); whatever_happens(); here(); console.profileEnd();}
  • Tip: delay initialization
  • // Immediate init$.ready(function() { function init() { // Do lots of stuff with #form } init();});// Delayed init$.ready(function() { function init() { // Do lots of stuff with #form } $(#form).one(mouseenter, init);});
  • PILLAR 3:RESPONSIVENESSGoing from user action to visual feedback
  • PILLAR 3: RESPONSIVENESS• Read High Performance JavaScript by Nicholas Zakas
  • Tip: throttle/debounce eventshttp://benalman.com/projects/jquery-throttle-debounce-plugin/
  • // Don’t do this:$(‘input’).on(‘keydown’, someHandler);// Do this:$(‘input’).on(‘keydown’, $.debounce(500, someHandler));
  • // Don’t do this:$(‘body’).on(‘mousemove’, someHandler);// Do this:$(‘body’).on(‘mousemove’, $.throttle(500, someHandler));
  • Tip: this one is easiest to fake
  • NEW PERSPECTIVES
  • Performance optimizations are expensive
  • Performance optimizations can increase costs
  • THEM
  • ME
  • PHOTOGRAPHS• http://www.flickr.com/photos/thehenryford/4929428611/• http://www.flickr.com/photos/thehenryford/4930039724/• http://www.flickr.com/photos/proctorarchives/6831872685/
  • THANK YOU menno.vanslooten@gmail.com @mennovanslootenThanks to Aan Zee (http://www.aanzee.nl) and the jQuery Foundation