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

Optimizing JS Apps to increase performance

Manan
August 04, 2015

Optimizing JS Apps to increase performance

Presented at the ThoughtWorks Werkstatt in Berlin as part of a meetup.

This talk will discuss how we can scale heavy JS applications without them becoming non-performant. With increasing capabilities of modern web browsers, different frameworks allow developers to do more with less amount of code. This however, may lead to situations in which the code written is not very efficient and may lead to performance bottlenecks upon scaling.

Manan

August 04, 2015
Tweet

More Decks by Manan

Other Decks in Technology

Transcript

  1. Why? “Whereas early web sites used JavaScript to perform simple

    tasks, the language is now used to run the entire user interface in many places.” “The best way to ensure a fast, enjoyable user interface is to write JavaScript as efficiently as possible for all browsers.” - Even faster websites, O’Reilly
  2. Why? “Whereas early web sites used JavaScript to perform simple

    tasks, the language is now used to run the entire user interface in many places.” “The best way to ensure a fast, enjoyable user interface is to write JavaScript as efficiently as possible for all browsers.” - Even faster websites, O’Reilly
  3. Garbage Collection “Only if something does not have a retaining

    path to the root node, it is garbage” - Google I/O 2013 - A Trip Down Memory Lane with Gmail
  4. Garbage Collection “Only if something does not have a retaining

    path to the root node, it is garbage” root object Node scalar Node - Google I/O 2013 - A Trip Down Memory Lane with Gmail
  5. Garbage Collection “Only if something does not have a retaining

    path to the root node, it is garbage” root object Node scalar Node {...} - Google I/O 2013 - A Trip Down Memory Lane with Gmail
  6. WeakMap() • Weak reference to keys and values • new

    WeakMap().keys • k 㱺 v, k must be an Object • k 㱺 v, if k is reachable then v is reachable Non enumerable
  7. Closures & Timers var myObj = { callMe: function ()

    { var myRef = this; var val = setTimeout(function () { console.log('Time is running out!'); myRef.callMe(); }, 1000); } }; myObj.callMe();
  8. Closures & Timers var run = function () {
 var

    str = new Array(1000000).join('*');
 var doSomethingWithStr = function () {
 if (str === 'something')
 console.log("str was something");
 };
 doSomethingWithStr();
 var logIt = function () {
 console.log('interval');
 };
 setInterval(logIt, 100);
 };
 setInterval(run, 1000); - http://point.davidglasser.net/2013/06/27/surprising-javascript-memory-leak.html