Just In Time Loader for JavaScript
November 27, 2007 @ 02:42 pm
The most recent version (1.0.0) can be downloaded here:…
Javascript’s Strange Threaded Nature
November 08, 2007 @ 02:38 pm
There's a lot of digging required to figure out if Javascript is single or multi-threaded, and for every article out there, at least three contradict it. Thanks to the work Dan Simard in June, a final answer on Javascript threads was reached. The only major problem in this was that the comments by a user to Simard's post indicated that alert() caused Firefox's execution chain to change. The result was while the prompt was on screen, setTimeout() and other assorted callback functions were free to resolve.
The problem is made worse with several setTimeout() calls. As a single thread, JavaScript maintains some sort of event stack, where all of the callbacks and timeouts pile up, waiting for their turn. Once the event stack is out of events, the timers start again to count down to execution. If you fire one call with a setTimeout() and a timeout value of 2 seconds, and one more second of code execution follows, there will still be 2 seconds on the timer since it has not had a chance to run.…