Thread:Pecoes/@comment-4674838-20121012013714/@comment-4674838-20121012152004

Hmmmm, that's too bad. There was one other time a few weeks ago when I would have liked to kill execution as well:
 * 1) Place a script in a MediaWiki page
 * 2) Put the script on a single page using
 * 3) Problem: Oftentimes (though not always) the script will execute before jQuery and mediaWiki variables are even defined, and crash

My naive solution: My assumption was "Well, the webpage will continue to load even while that loop is running. Eventually, those variables will be defined and we'll exit the loop." -- that turned out to be a very poor assumption that again froze up the console, though the rest of my browser was fine.

A better solution would have been to maybe use setTimeout or setInterval to check every 100 milliseconds or something like that. Ultimately, I ended up packaging the script for installation in MediaWiki:Common.js instead of with verbatim tags, since you at least have the guarantee that jQuery and mediaWiki will be defined already.