Created
June 14, 2011 03:20
-
-
Save erikvold/1024242 to your computer and use it in GitHub Desktop.
A include() function for restartless Firefox add-ons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Includes a javascript file with loadSubScript | |
* By Erik Vold <erikvvold@gmail.com> http://erikvold.com/ | |
* | |
* @param src (String) | |
* The url of a javascript file to include. | |
*/ | |
(function(global) global.include = function include(src) { | |
var o = {}; | |
Components.utils.import("resource://gre/modules/Services.jsm", o); | |
var uri = o.Services.io.newURI( | |
src, null, o.Services.io.newURI(__SCRIPT_URI_SPEC__, null, null)); | |
o.Services.scriptloader.loadSubScript(uri.spec, global); | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm pretty certain Mozilla's main motivation for creating the
bootstrap.js
is solely to support restartless addons as best they could design such a thing at the time.bootstrap.js
files have to be evaluated during startup (if enabled) which I suspect would diminish startup times for most addons by default. Since most old school addons usually only evaluate code after a chrome window has been overlayed.Sync code is worse than async code though, and Mozilla is trying converting to the latter style quite a bit, mainly because it will/might be required for e10s. But this doesn't have much to do with
bootstrap.js
.