Does performance matter?
Best practices
Seven interesting findings
4 frameworks focused on performance for mobile
Web Inspector, your best friend
Live refresh workflow
Agenda § Does performance matter? § Best practices § Seven interesting findings § 4 frameworks focused on performance for mobile § Web Inspector, your best friend § Live refresh workflow 2
7 Does performance matter? Source: http://www.businessinsider.com/10-golden-principles-successful-web-apps-2010-3 10 Golden Principles Of Successful Web Apps by Fred Wilson, from a talk he gave at the Future Of Web Apps conference in Miami in February of 2010 § Speed is always the most important feature § Your service must be useful right away, not after an hour of set-up § Your software should have a personality and voice § Less is always more when you first launch § Make your app programmable -- allow others to add on to it in some way § Individuals should be able to personalize your app (both users and programmers) § Make sure everything in your application has a unique, comprehensible URL § Build your app so that it's optimized to be found in terms of both social media and search § Make it visually clean § Be playful -- you can turn anything into a game
15 Memory & Images The largest contributors to unnecessary memory use are: § Loading invisible UI § Un-optimized Image Assets § Pre-loading and caching data into memory USE JPEG FOR for non-transparent images USE PNG FOR for transparent images
16 JavaScript setTimeout() Ask yourself: § How much of this JS has to get done right now? § How much of this JS has to get done eventually? UI THREAD § UI THREAD is used both for JavaScript execution and UI Updates § UI cannot be updated while JavaScript is executing § Keep JavaScript execution to 50ms using Timers or WebWorkers
Valuable recommendations § Don’t touch the DOM § Cache DOM preferences in local vars § Cache the length when looping collections § Batch style changes (reflow) § Use fewer images, more CSS (bandwidth) § Worry about asset management (minification, gzipping, CDNs) § Be careful with Page Transitions and Page Refreshing (very expensive) § Design mobile first § Design single page apps whenever possible § Use animation frameworks such as GreenSock § Avoid locking the UI Thread (WebWorkers or Timers) § Test, test, test (JSPerf, BrowserScope, WebInspector) 18
21 What did I use? http://www.broofa.com/Tools/JSLitmus/ JSLitmus is a lightweight tool for creating ad-hoc JavaScript benchmark tests. Features include: Single-file install (JSLitmus.js) Works on Firefox, Opera, Safari, IE, Google Chrome, and iPhone browsers Adaptive test cycles - tests take ~1-2 seconds, regardless of the operation Google Chart + TinyUrl integration Open Source MIT-style license
22 Seven interesting findings 1.Object.create() vs new Object() 2.One Ajax call (processed locally) vs Multiple Ajax Calls 3.Local Storage vs Session Storage vs SQLite 4.display:none vs Destroy Element 5.bbUI (need Ripple to view) vs jQuery Mobile (creating 1000 buttons) 6.Minified JS vs Non-Minified JS 7.Web Workers vs Main Thread ALL TESTS (ONLINE): www.dborba.com/download/webworks-stress-test
24 jQuery Mobile http://jquerymobile.com § Easy to write (no need for heavy JS work) § Theme Roller & Codiqa (visual tool) § Does well with single page apps § Built upon jQuery UI § Runs on iOS, Android, BlackBerry, Bada, Windows Phone, WebOS and more § Has a builder tool (alpha)
25 Sencha Touch http://www.sencha.com/products/touch § MVC like § Focused on commercial products § Training & Support § Runs on OS, Android, BlackBerry, Windows Phone, and more.
26 Lungo.js http://lungo.tapquo.com § Created to run on low end devices § Robust API § Community Driven (GitHub) § Runs on iOS / Android / Blackberry / FirefoxOS
27 bbUI.js https://github.com/blackberry/bbUI.js § Niche specific, (BlackBerry 10 look and feel) § Follows BlackBerry 10 User Experience Guidelines § Community Driven (GitHub) § OFF DOM Implementation § UI only
28 Built for BlackBerry HTML5 Sample https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/Built-For- BlackBerry http://developer.blackberry.com/builtforblackberry
29 Visual tool from the Community Creating your first BlackBerry 10 App Video tutorial and download: http://dborba.com/meet-gap-alpha-for-html5-no- need-to-use-command-line-anymore/
Recap 36 § Does performance matter? § Best practices § Seven interesting findings § 4 frameworks focused on performance for mobile § Web Inspector, your best friend § Live refresh workflow