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
Post a Comment