ad

Chillout.js Helps you in reducing Javascript CPU usage

chillout.js

Javascript also loads on CPU if you are using complex statements like loop through an array. If a script takes time in executing, old browsers like IE shows warning saying “Unresponsive Script”. It also increases the web page load time and also irritates visitors.

To avoid this issue, you can try Chillout.js. It manages your script and adds delay if the processing is heavy to main the CPU stability. In this way, it will execute your script fine without any kind of browser warnings.

You can use it in any JavaScript environment (Browser, Electron, Node.js).

Usage is also simple

function heavyProcess() {
  var v;
  for (var i = 0; i < 5000; i++) {
    for (var j = 0; j < 5000; j++) {
      v = i * j;
    }
  }
  return v;
}
var time = Date.now();
for (var i = 0; i < 1000; i++) {
  heavyProcess();
}
var processingTime = Date.now() - time;
console.log(processingTime);

chillout.repeat

var time = Date.now();
chillout.repeat(1000, function(i) {
  heavyProcess();
}).then(function() {
  var processingTime = Date.now() - time;
  console.log(processingTime);
});

Tags: |
Nord VPN Sale

Deepanker Verma is the founder of Techlomedia. He is a tech blogger, developer and gadget freak.


Similar Articles

0 Comments

Leave a comment

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.

2020 UseThisTip | Developed By Deepanker