What causes my browser saying my Javascript is running SLOW?
Honestly, I didn’t realize Microsoft did publish this article to explain how and why IE will claim your Javascript is running slow and being unresponsive, until I was directed by an article in Ajaxian.
Here is the summary
IE
5 million statements executed. (not number of lines of codes). I cannot really argue whether or not it is a good idea to evaluate the slowness of the script by number of statements executed, but with today web development trend and the growing number of third party Javascript library (jQuery, YUI etc), It is actually difficult to control this number, and it is up to the third party library developers if they want to take it seriously.
Firefox
10 seconds (script time)
Safari
5 seconds (script time)
Chrome
Reason still unknown yet
Opera
Appear not to have such feature
For a detail explanation, you probably want to visit this original article.
***************************
I have got a few complex Ajax applications running in my company. One example is to load the customers’ purchase orders into our system. It works mostly fine, when there are less than 50 lines in the order, but as the order is getting bigger and bigger, the lines of statements multiplied and it means this warning message is unavoidable. Although I can still see a lot of room to improve the script and I feel I can cut the size of the scripts by half (and 2 to 3 times faster hopefully), I don’t think they are interested in getting this performance upgrade as they need me to work on the manipulating the price list (more than 30k items, shouldn’t I spend the time writing more robust programs?) and other data warehousing issues.
Fortunately, in the knowledgebase of Microsoft, I can increase the limit of statements executed. Hopefully we can use it as a temporary workaround. To make it simple, try these codes:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles]
“MaxScriptStatements”=dword:00989680
Save it as a *.reg file, and then open (import) it with Registry Editor (regedt32.exe) It will double the limit to 10 millions statements executed. The DWORD value basically is the hexadecimal representation of 10 millions. You can welcome to try different value. To me, I made it 8 times larger as a workaround.