Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created May 2, 2011 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfsiii/951935 to your computer and use it in GitHub Desktop.
Save jfsiii/951935 to your computer and use it in GitHub Desktop.
Function I run when Express starts up
function preloadFlot()
{
var jsdom = require("jsdom"),
document = jsdom.jsdom(),
window = document.createWindow(),
flot_location = 'http://jsno.de/javascripts/jquery.flot.svn.js',
text_location = 'http://jsno.de/javascripts/jquery.flot.text.js',
jquery_location = 'http://code.jquery.com/jquery-1.5.min.js',
loadScript = function ( location, callback )
{
var script = document.createElement("script");
script.src = location;
if (callback) script.onload = callback;
document.head.appendChild(script);
return script;
};
window.Canvas = require('canvas');
loadScript(jquery_location, function (){
global.jQuery = window.$;
loadScript(flot_location, function () { loadScript(text_location); });
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment