
Optimizing heavy JavaScript
- Transfer
Note: the following is a translation of the note from the blog of YUI utilities developer Julien Lecomte "Running CPU Intensive JavaScript Computations in a Web Browser" , in which the author considers the implementation of "heavy" calculations in a web browser and provides a number of methods for their "optimization". My comments are in italics.
The template that I want to discuss below is well known and has been used for over 10 years. The purpose of this note is to present this template in a new light and, more importantly, to discuss possible ways to reduce overhead costs.
The most significant obstacle to performing “heavy” calculations in a web browser is the fact that the entire user interface in the browser stops and waits for the JavaScript code to finish executing. This means that under no circumstances should it be allowed for the script to take more than 300 ms to complete (or better if it is much less). Violation of this rule will inevitably lead to poor user experience .
In addition, in web browsers, the JavaScript process has a limited time to complete its execution (it can be like a fixed number - in the case of browsers on the Mozilla engine - or some other restriction, for example, the maximum number of elementary operations - in the case of the Internet Explorer). If the script runs too long, the user is presented with a dialog box asking if the script should be interrupted.
read more on webo.in →
Introduction
The template that I want to discuss below is well known and has been used for over 10 years. The purpose of this note is to present this template in a new light and, more importantly, to discuss possible ways to reduce overhead costs.
The most significant obstacle to performing “heavy” calculations in a web browser is the fact that the entire user interface in the browser stops and waits for the JavaScript code to finish executing. This means that under no circumstances should it be allowed for the script to take more than 300 ms to complete (or better if it is much less). Violation of this rule will inevitably lead to poor user experience .
In addition, in web browsers, the JavaScript process has a limited time to complete its execution (it can be like a fixed number - in the case of browsers on the Mozilla engine - or some other restriction, for example, the maximum number of elementary operations - in the case of the Internet Explorer). If the script runs too long, the user is presented with a dialog box asking if the script should be interrupted.
read more on webo.in →