Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Optimizing JavaScript Runtime Performance for T...

Optimizing JavaScript Runtime Performance for Touch - Velocity 2013

Stephen Woods

June 19, 2013
Tweet

More Decks by Stephen Woods

Other Decks in Technology

Transcript

  1. getData  =  function(key,  callback)  {    if(cache[key])  return  cache[key];  

     $.get('/data.json',  function(data){        cache[key]  =  data;        callback(data);    } } myDAL.getData('key',  callback);
  2. var  offsetCache  =  {}; function  getOffsetHeight(id)  {      

     if(offsetCache[id])  {                return  offsetCache[node.id];        }  else  {                offsetCache[id]  =                          document.getElementById(id).offsetHeight        } }
  3. function  handleXHR(resp)  {    if(isSwiping)  {        setTimeout(function(){

                   handleXHR(resp);        },20);    }    processData(desp); }
  4. • Load image ~ 300ms (async) • Find Faces ~

    100ms (sync) • Compute Entropy Crop ~ 30ms (sync) • Smooth Animation (sync)
  5. slide1.style.transition  =  transitionDuration  +            

                                             's  transform  ease-­‐out'; slide1.style.transform  =  computedEndFrame;
  6. • Cache data where possible • Update the UI on

    events, use transforms when possible • Multitask when you can, both with threads and yeilding