Load JavaScript at runtime
From Cyclone3 Wiki
If you need to programatically load a standalone JavaScript file at XUL/XBL runtime, you can do so using:
var service = Components
.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
service.loadSubScript("chrome://path.to/file.js");
