But how does a browser determine when a script has run for too long? As you’d expect, the top 5 vendors implement different techniques and limits…
Firefox uses a timed limit of 10 seconds.
Safari uses a timed limit of 5 seconds.
Chrome does not limit execution but detects when the browser crashes or becomes unresponsive.
Several of the browsers allow you to configure the execution limit parameters, but that’s not something I’d recommend. I won’t publish the details here because someone, somewhere will use it as a “fix” for their unresponsive page! Google it if you like, but tweaking browser settings for badly-behaved code does not address the root of the problem.
If you want to read more from Craig, subscribe to our weekly tech geek newsletter, Tech Times.
Craig is a freelance UK web consultant who built his first page for IE2.0 in 1995. Since that time he's been advocating standards, accessibility, and best-practice HTML5 techniques. He's created enterprise specifications, websites and online applications for companies and organisations including the UK Parliament, the European Parliament, the Department of Energy & Climate Change, Microsoft, and more. He's written more than 1,000 articles for SitePoint and you can find him @craigbuckler.