Fine Tuning
Hybrid Mobile Apps
So, what is a
hybrid?
Perception of Performance
0.1 second
1 second
10 seconds
Weber-Fechner Law
20%noticeable
improvement
Button Response
• The dreaded 300ms delay
300 ms 0 ms
Button Response
• Use click library:
– Fastclick.js
– Angular Touch
• Disable zoom
Button Response
• Use div and ng-click
Define Button Active State
Mobile Network
• Network latency is the greatest contributor of
slooow response.
• Thus, reduce network access.
• Should we render pages from the server?
Use Single Page App
Or Appgyver Multipage App
Enable Gzip Compression
60 - 70% Compression
Enable gzip support on server.
mod_gzip, server.xml, etc.
Enable gzip support on client, if necessary.
Enable Gzip Compression
Check using Chrome Developer Tool > Network.
Use Websocket
• Websocket is already supported using Javascript
on mobile.
• Transfer data in JSON format. Encoding and
decoding is built-in using Javascript
Handle Offline and Slow Network
• Check if online using navigator…
Handle Offline and Slow Network
1. Setup a timer
Handle Offline and Slow Network
Use Status Indicators
• Native Shell
• Native Navigation
• Webview Content
David Heinemeir Hansson,
Creator of Ruby on Rails
Database Queries
• Usual SQL Query optimization applies
• Using paging with unlimited scroll
– Append LIMIT X OFFSET Y in SQL Query
– Check end of scroll
Displaying Lists and Scrolls
• when displaying with
more than 300 items:
– Review UX
– Avoid ng-repeat, or use
‘track by’ to avoid
rebuilding the DOM
– Use plain Javascript and
database query
Displaying Lists and Scrolls
Displaying Lists and Scrolls
• Reverting to angular scope from Javascript
Use Full Text Search
• Hooray! SqlLite supports Full Text Search
(FTS3, FTS4)
CREATE VIRTUAL TABLE papers USING fts3(subject,
body);
SELECT * FROM mail WHERE body MATCH 'sqlite';
• Test Results with over 100k records - FTS is
61% faster than ‘like’
Local Storage
• Store data on local as cache
– Local Storage
– Local Database
• Use local storage for temporary storage.
• Use database for persistent storage.
http://gonehybrid.com/dont-assume-localstorage-will-always-
work-in-your-hybrid-app/
CSS Animation
CSS Animation
Track Events and Error
• User activity and events are crucial to
usability.
• Tracking events is key to great application
design.
• Several solutions available: Crashlytics,
Rollbar, Mixpanel, Google Analytics,
Minimize Browser Reflow
• Generated HTML offline
• Reduce depth of DOM
• Avoid unnecessary complex CSS selector
Other Rendering Tips
• Optimize images to avoid resizing
• Use SVG instead of Images
• Use image sprites
• Avoid Shadows and Gradients
• Consider using SPDY / HTTP2 Protocol
• Use Crosswalk
Chrome Dev Tools
Chrome Dev Tools
Unit Tests
• Jasmine and Karma for Behavior Driven
Testing
Thank You
Allan C. Tan, SCEA, PMP
CEO/President
Email: allan@ideyatech.com
http://www.ideyatech.com/
allanctan
@allanctan ph.linkedin.com/in/allanctan/
Resources
• http://social.technet.microsoft.com/wiki/contents/article
s/27828.windows-phone-cross-platform-mobile-
architecture.aspx
• https://signalvnoise.com/posts/3743-hybrid-sweet-spot-
native-navigation-web-content
• https://engineering.linkedin.com/mobile/linkedin-ipad-
nativeweb-messaging-bridge-and-websockets
• http://blog.smartbear.com/web-monitoring/all-im-
offering-you-is-the-truth/
• http://www.nngroup.com/articles/powers-of-10-time-
scales-in-ux/

Fine tuning Hybrid Mobile App

Editor's Notes

  • #6 Basecamp is 90% html and 10% native.
  • #8 10 secs – keep user’s focus 1 secs – keep user flow of thought 0.1 secs – feels instantaneous
  • #9 Why is there a 300ms delay? Let's suppose the user touches a link in iOS Safari. Because the user has the ability to double tap to zoom or scroll, whenever the user touches the screen, the browser does not instantaneously know whether the user meant to click the link, or is double tapping. Therefore iOS Safari waits 300ms after the first tap to see if the user taps again.
  • #13 When pages are rendered from the server, updates are easier to deploy. However, latency will make response slower.