Slow Script error in Safari while browsing

Question: When browsing with Safari on my MacBook Pro I am often getting the error message: Slow Script, Safari is no longer responding because of a script on the webpage “www.abcdefg.com” (http://abcdefg.com/). Do you want to stop running the script, or let it continue?. This alert frequently appears on web sites like espn.com or gmail.com. I have tried resetting Safari, resetting the computer, repairing disk permissions but none of the usual things are working. What’s wrong with my Safari? Answer: You have done nothing wrong and your Safari is working fine. Safari, like Firefox or Internet Explorer, uses script engine execution time to determine when a script has become long-running. It looks like the default timeout is around 5-20 seconds. When that threshold is reached, the error message box is displayed. In most cases the error goes back to a badly written script, mainly a JavaScript code or a Flash script, on the websites you are visiting. A lot of sites use Adobe Flash animations, menus and advertisements that usually require a lot of data to be downloaded to your computer, and as you can see, sometimes this alarm pops up. The embedded Flash Player posts an alert when a single script continues to run for 15 seconds or longer, giving viewers the option to end the script. The solution to this alert can vary, just as the specific cause will vary from web sites to web sites. The alert itself is not really the problem, it does not harm your computer but your nerves. The real problem is the performance of the web application you want to use, such as google mail, while one of their flash scripts (such as terrible written chat module) drives you crazy. This error message prevents you from closing the application because you believe it is crashing while you have to wait 15 seconds for the application to become responsive. The most common cause of a long delay is loading large amounts of data, or manipulating large amounts of data, or using time-intensive string/array codes in client-side codes. The whole story is about (1) the battle between Apple and Adobe, and (2) some terrible web programmers, whose code is trying to do too much at once. Many of them do not know that Adobe’s Flash has a built-in 15 second timeout for a script loop in a single frame before it gives the warning. They should think of the real world with slow connections and down to earth client computers, so they should load movie, audio or document data in small chunks and split their lengthy codes. This may solve a variety of problems in their application, and as a side benefit it avoids triggering the timeout alert. Their code may not run as quickly as a pure block of code on a fast machine, but if heavy manipulation is required, they can make their application more accessible. On the other hand Adobe’s Flash Player is not the most reliable code we can imagine. What can you do? Call the webmaster or customer service of the web sites you would like to use. Tell them to write a better code and let you use their services through pure html pages as an option. Work-around solution Sometimes it works but you have to know what you are doing :-) Please note that the “solution”, ie. disabling the timer will just mask the problem: 1. You need to access the Safari Debug Menu 2. When the Debug Menu is activated, click on it in the menu bar and uncheck “Enable Runaway JavaScript Timer” (pre Safari 4) or check Develop -> “Disable Runaway JavaScript Timer” (Safari 4+) If the Debug/Develop menu is not available: 1. Quit Safari. Open Terminal.app in your Utilities folder. 2. Copy & paste the following command into the window:
defaults write com.apple.Safari IncludeDebugMenu 1
3. Press “return”. When you see your Mac’s name as command prompt, it’s done, 4. Quit Terminal 5. Restart Safari and go to the Debug or Develop menu, following the suggestion above. In Safari 4 the Develop menu is enabled using the Preferences… -> Advanced but the debug menu is enabled using the defaults command as you can see above. The two together are roughly the same as the debug menu in Safari 3. Have fun with your Mac! Microsoft Windows This work-around solution also works in Safari for Windows, but requires editing the file: c:\Documents and Settings\username\Application Data\Apple Computer\Preferences\com.apple.safari.plist. Internet Explorer 8 Internet Explorer prompts the user to decide whether they would like to continue running a slow script. IE pops up a Stop running this script? error message. The script time-out value can be changed by modifying a registry entry. Details are here. Comments Updated on July 1, 2010 Neither Apple (Safari) nor Adobe (Flash Player) is innocent in their private war. If you are hoping that Apple or Adobe will offer us a solution, then you have to wait a little bit. Adobe plans to distribute v10.1+, a new major version of Flash Player offering safer code this summer. Update: Flash Player 10.1 for Windows, Mac, and Linux platforms was released on Adobe.com on June 10, 2010. Flash Player 10.1 for Solaris was released on Adobe.com on June 23, 2010: prerelease information is here. Download the latest Flash Player from here and let’s hope the best. Comment on March 19, 2010: Simply download and use Firefox or Internet Explorer when your Safari browser, Flash player and web programmers, in a close cooperation, try to kill your nerves. Update on April 22, 2010: Guys, no good news. Apple-Adobe war deepens. Faced with Apple’s new rule, Adobe pulled the plug on Packager for iPhone. Adobe will no longer pursue its plans to bring Flash to Apple’s iPhone and the iPad. Apple (and Adobe) seems more deeply concerned with digging Flash’s grave than it does with finding solutions for plug-ins. Update: Adobe Flash Player 10.1 now supports several mobile platforms. Targeted mobile operating systems include Android, Windows Phone 7, Palm webOS, Symbian, and BlackBerry. iPhone is not available.