fast and efficient
play

FAST and EFFICIENT Tizen HTML5 mobile applications AKI SAARINEN, - PowerPoint PPT Presentation

FAST and EFFICIENT Tizen HTML5 mobile applications AKI SAARINEN, REAKTOR JAPAN @akisaarinen http://reaktor.co.jp/en/ FAST & EFFICIENT # # 1 Measure! 2 Start-up time 3 Run-time performance # 1 MEASURE! #


  1. FAST and EFFICIENT Tizen HTML5 mobile applications AKI SAARINEN, REAKTOR JAPAN @akisaarinen http://reaktor.co.jp/en/

  2. FAST & EFFICIENT ‹#›

  3. ‹#›

  4. 1 Measure! 2 Start-up time 3 Run-time performance ‹#›

  5. 1 MEASURE! ‹#›

  6. “ Measure before optimizing — a wise man ‹#›

  7. Available tools • WebKit Web Inspector • Tizendev: start-up • Tizendev: framerate ‹#›

  8. WebKit Web Inspector ‹#›

  9. TizenDev • Automated deploying of app • Automated start-up timing • Automated FPS measurements • http://github.com/reaktor/tizendev ‹#›

  10. TizenDev: start-up time runs: ¡ ¡ ¡ ¡ ¡30 ¡ mean: ¡1708ms ¡ std: ¡ ¡ ¡ ¡63ms ‹#›

  11. TizenDev: framerate samples: ¡ ¡ ¡ ¡100 ¡ mean: ¡ ¡ ¡ ¡58 ¡FPS ¡ std: ¡ ¡ ¡ ¡ ¡ ¡4 ¡FPS ‹#›

  12. Available tools • WebKit Web Inspector • Tizendev: start-up • Tizendev: framerate ‹#›

  13. 2 START-UP ‹#›

  14. LESS IS MORE ‹#›

  15. • Lazy-loading • Minification • Reflow • Native API calls • Parallelization ‹#›

  16. Large codebase, all loaded and parsed at start-up time ‹#›

  17. Large codebase, all loaded and parsed at start-up time ‹#›

  18. Code to show first screen Modularized pieces to show other views on-demand ‹#›

  19. UglifyJS 1 kilobyte ~= 1 ms ‹#›

  20. Avoid reflow ‹#›

  21. Avoid reflow REALLY! ‹#›

  22. Example: Calling width() of an element ‹#›

  23. � container.find("li").each(function() ¡{ ¡ ¡ ¡var ¡listItem ¡= ¡$(this); ¡ ¡ ¡listItem.text(item.width()); ¡ }); ¡ � forces reflow ‹#›

  24. container.detach(); ¡ � container.find("li").each(function() ¡{ ¡ ¡ ¡var ¡listItem ¡= ¡$(this); ¡ ¡ ¡listItem.text(item.width()); ¡ }); ¡ � container.appendTo($("body")); ¡ ‹#›

  25. container.detach(); ¡ � container.find("li").each(function() ¡{ ¡ ¡ ¡var ¡listItem ¡= ¡$(this); ¡ ¡ ¡listItem.text(item.width()); ¡ }); ¡ � container.appendTo($("body")); ¡ ‹#›

  26. 1000 elements (MacBook Pro) � 2000 ms 60 ms ‹#›

  27. Native API s • Defer execution • Use localstorage • Only fetch needed data ‹#›

  28. Parallelize • Resources • Service calls ‹#›

  29. ‹#›

  30. ‹#›

  31. • Do lazy-loading • Use minification • Avoid reflow • Careful with native APIs • Parallelize ‹#›

  32. 3 RUN-TIME ‹#›

  33. 60 FPS ‹#›

  34. • DOM modifications • Pre-loading • CSS3 transitions • Scrolling ‹#›

  35. DOM = SLOW ‹#›

  36. display: none; � + 5-10 FPS ‹#›

  37. 1 2 3 (pre-load) visible (pre-load) ‹#›

  38. Accelerated CSS3 transitions ‹#›

  39. NO: jQuery.animate() YES: CSS3 ‹#›

  40. NO: left: 0px -> 100px YES: translate3d() ‹#›

  41. NO: background-color: ...; YES: opacity: 0.2; ‹#›

  42. Enable 3D acceleration -webkit-transform: translate3d(0,0,0); http:/ /stackoverflow.com/questions/3461441/prevent-flicker-on-webkit-transition-of-webkit-transform ‹#›

  43. Trigger animation in next render cycle ‹#›

  44. setTimeout ( function () ¡{ ¡ ¡ ¡element. css ( ¡ ¡ ¡ ¡ ¡“-­‑webkit-­‑transform”, ¡ ¡ ¡ ¡ ¡“translate3d(100,0,0)” ¡ ¡ ¡); ¡ }, ¡0); ‹#›

  45. Momentum scrolling iScroll or other JavaScript library NO: overflow: scroll; NO: YES: -webkit-overflow-scroll: touch; ‹#›

  46. • DOM is slow • Do pre-loading • Use CSS3 transitions • Use overflow scrolling ‹#›

  47. 1 Measure! Re-cap! 2 Start-up time 3 Run-time performance ‹#›

  48. • Performance is important • Measure before optimizing • Minimize actions at start-up • Pay attention to FPS ‹#›

  49. Thank you! @akisaarinen ‹#›

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend