Dynamically changing javascript function for efficiency -


my question has optimizing javascript code more efficient.

i have function called code inside needed called once, so:

function removeblankcanvas() {     if ( --numberofchartsstillloading == 0 ) {         //do stuff     } } 

this works fine function still called countless times after numberofchartsstillloading 0, , know never 0 again. i'm thinking doing this:

function removeblankcanvas() {     if ( --numberofchartsstillloading == 0 ) {         //do stuff          removeblankcanvas = function() {             return true;         }     } } 

could more efficient code? instance, if function called millions of times? i'm asking strictly curiosity's sake.

your performance bottleneck unlikely simple if statement.

this trick cause unexpected result, because functions immutable, , have callbacks keep reference original function, after changed name reference function.

my 2 cents: find real performance issues optimize.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -