Revision of Twine: loading jQuery without editing the HTML from Thu, 04/25/2013 - 00:27

You can load jQuery into your Twine game via Google Hosted Libraries using this simple script code:

(function(){
  var s = document.createElement('script');
  s.src = 'http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js';
  document.body.appendChild(s);
  setTimeout(function f(){ 
    if (jQuery) {
      $.noConflict(); 
      jQuery(document).ready(function() {
        //whatever
      });
    } else setTimeout(f,1);
  },1);
}());

Change whatever you want the function passed to ready() to do.
Notes:
* Since Twine's engine uses '$' for something, jQuery must sadly relinquish that convenient abbreviation.
* Due to a minor bug, Twine's runtime currently doesn't work at all in IE 8 or below, so there's not much reason to use jQuery 1.9 over 2.0
* Using Google Hosted Libraries of course means that people can't play your game without a live internet connection - which, in the extremely rare chance you intend your Twine game to be available offline, should be borne in mind. Nevertheless, it can be more convenient for you, the author, due to not having to provide the jQuery file yourself.