3 ms·
That's direct consequence of how JS/DOM is designed to work. IE is not the only browser that has UI thread tied to JS execution. Although browser chrome could
by pornel 15y ago
That's direct consequence of how JS/DOM is designed to work. IE is not the only browser that has UI thread tied to JS execution.
Although browser chrome could run in a separate thread, that wouldn't prevent page itself (and any interaction with it) from "freezing".
This is because any interaction with the page is fired as JS events, and if JS is busy, it can't pick those events.
Browser can't react to any clicks (even links and buttons can't be activated, because JS is given chance to intercept and cancel those clicks).
Even if you want to leave the page, beforeunload/unload events will get queued.
Also pages need to be refreshed only between JS events (that's how DOM animation works, that's how canvas buffering is specced), so even screen redraw is tricky when JS is executing.
- AshleysBrain 15y agoBut shouldn't the page at least run in its own thread (or process)? If Javascript hangs, sure the page can hang, but the browser UI should still work and give you the opportunity to terminate or recover. According to TFA, Javascript blocks the UI thread in IE9. Their own guidelines that they link to [1] says "Do not: call into any 'unknown' code from your UI thread". I don't see why a browser is special and can't keep to that rule - especially a modern browser like IE9. [1] http://msdn.microsoft.com/en-us/library/dd744765(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/dd744765(v=vs.85).as...
- justsomedood 15y agoBy the UI they mean the controls inside of the page, not the browser's UI - your back, refresh and other browser controls still work. The same thing happens if you have javascript that consumes CPU and doesn't return for a long period of time. While the javascript is running controls on the page don't work such as buttons and select lists, but when the javascript finishes the UI thread regains control and responds to input again.