Page Updated: March 08, 2005
Latest Version: 0.1.375
Debug | Install | File I/O | RDF | Network | Sound | Utils | XUL | Zip
Home | Mailing List | Install | Source Code | Downloads | Bugs | docs | clients

Ensuring jsLib is available to your extension

There has been a lot of problems caused by installing jsLIb as an extension using install.rdf. What this does is place jsLib in the user chrome when it really needs to be in the global chrome. This has also caused extension authors to take pieces of jsLib and include it in their extensions source code. The problem is jsLib was designed to be shared by all extensions and moz apps across profiles. Taking pieces and dismantling the library has created many problems. To rectify this, I have come up w/ some simple code you can use to ensure jsLib is installed.

If you have an extension and you are using jsLib as a dependency, then paste the code below into your extension source and call on the jslibCheckInst func when you initialize your extension.

The example below will prompt a user to install jsLib if it is not already installed.

// ensure jsLib is installed
function jslibCheckInst ()
  if (typeof(jslib) != "object") {
    const msg = "MyExtension requires jsLib to properly operate\n"
              + "Would you like to install jsLib now? (browser restart required)";

    if (confirm(msg)) {
      const url = ""
                + "jslib_current_global_signed.xpi";
      try {
        _content.location = url;
      } catch (e) { open(url, "_blank", "width=1,height=1"); }

    throw "Stopping any further code execution ...";

The jslib project can be contacted through the mailing list or the member list.
Copyright © 2000-2020. All rights reserved. Terms of Use & Privacy Policy.