JavaScript code modules

  • Revision slug: Mozilla/JavaScript_code_modules
  • Revision title: JavaScript code modules
  • Revision id: 348915
  • Created:
  • Creator: mnoorenberghe
  • Is current revision? No
  • Comment sort and normalize list of standard modules

Revision Content

{{gecko_minversion_header("1.9")}}

JavaScript code modules let multiple privileged JavaScript scopes share code. For example, a module could be used by Firefox itself as well as by extensions, in order to avoid code duplication.

General topics

Using JavaScript code modules
An introduction to how to use JavaScript code modules.
Component.utils.import
How to import a JavaScript code module.
Component.utils.unload {{gecko_minversion_inline("7.0")}}
How to unload a JavaScript code module.
Code snippets: Modules
Examples of how to use code modules.
Mozilla Labs JS Modules
This page features a list of JS modules, along with download links and documentation, that extension developers can use in their code.

Standard code modules

AddonManager.jsm {{gecko_minversion_inline("2.0")}}
Interface to install, manage, and uninstall add-ons.
AddonRepository.jsm {{gecko_minversion_inline("2.0")}}
Allows searching of the add-ons repository.
ctypes.jsm {{fx_minversion_inline("3.6")}}
Provides an interface that allows JavaScript code to call native libraries without requiring the development of an XPCOM component.
DeferredTask.jsm {{gecko_minversion_inline("18.0")}}
Run a task after a delay.
Dict.jsm {{gecko_minversion_inline("5.0")}}
Provides an API for key/value pair dictionaries.
DownloadLastDir.jsm {{gecko_minversion_inline("2.0")}}
Provides the path to the directory into which the last download occurred.
FileUtils.jsm {{gecko_minversion_inline("1.9.2")}}
Provides helpers for dealing with files.
Geometry.jsm {{gecko_minversion_inline("2.0")}}
Provides routines for performing basic geometric operations on points and rectangles.
ISO8601DateUtils.jsm
Provides routines to convert between JavaScript Date objects and ISO 8601 date strings.
NetUtil.jsm
Provides helpful networking utility functions, including the ability to easily copy data from an input stream to an output stream asynchronously.
openLocationLastURL.jsm {{gecko_minversion_inline("1.9.1.4")}}
Provides access to the last URL opened using the "Open Location" option in the File menu.
PerfMeasurement.jsm {{fx_minversion_inline("4.0")}}
Provides access to low-level hardware and OS performance measurement tools.
PluralForm.jsm
Provides an easy way to get the correct plural forms for the current locale, as well as ways to localize to a specific plural rule.
PopupNotifications.jsm {{gecko_minversion_inline("2.0")}}
Provides an easy way to present non-modal notifications to users.
Services.jsm {{gecko_minversion_inline("2.0")}}
Provides getters for conveniently obtaining access to commonly-used services.
source-editor.jsm {{fx_minversion_inline("11.0")}}
The Source Editor is used by developer tools such as the Style Editor; this interface implements the editor and lets you interact with it.
XPCOMUtils.jsm
Contains utilities for JavaScript components loaded by the JS component loader.

Revision Source

<div>
  {{gecko_minversion_header("1.9")}}</div>
<p>JavaScript code modules let multiple privileged JavaScript scopes share code. For example, a module could be used by Firefox itself as well as by extensions, in order to avoid code duplication.</p>
<table class="topicpage-table">
  <tbody>
    <tr>
      <td width="50%">
        <h2 id="General_topics">General topics</h2>
        <dl>
          <dt>
            <a href="/en-US/docs/JavaScript_code_modules/Using" title="./Using">Using JavaScript code modules</a></dt>
          <dd>
            An introduction to how to use JavaScript code modules.</dd>
          <dt>
            <a href="/en-US/docs/Components.utils.import" title="Components.utils.import">Component.utils.import</a></dt>
          <dd>
            How to import a JavaScript code module.</dd>
          <dt>
            <a href="/en-US/docs/Components.utils.unload" title="Components.utils.unload">Component.utils.unload</a> {{gecko_minversion_inline("7.0")}}</dt>
          <dd>
            How to unload a JavaScript code module.</dd>
          <dt>
            <a href="/en-US/docs/Code_snippets/Modules" title="Code_snippets/Modules">Code snippets: Modules</a></dt>
          <dd>
            Examples of how to use code modules.</dd>
          <dt>
            <a class="external" href="http://wiki.mozilla.org/Labs/JS_Modules">Mozilla Labs JS Modules</a></dt>
          <dd>
            This page features a list of JS modules, along with download links and documentation, that extension developers can use in their code.</dd>
        </dl>
        <dl>
        </dl>
      </td>
      <td width="50%">
        <h2 id="Standard_code_modules">Standard code modules</h2>
        <dl>
          <dt>
            <a href="/en-US/docs/Addons/Add-on_Manager" title="Addons/Add-on_Manager">AddonManager.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
          <dd>
            Interface to install, manage, and uninstall add-ons.</dd>
          <dt>
            <a href="/en-US/docs/Addons/Add-on_Repository" title="Addons/Add-on Repository">AddonRepository.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
          <dd>
            Allows searching of the add-ons repository.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/js-ctypes" title="./ctypes.jsm">ctypes.jsm</a> {{fx_minversion_inline("3.6")}}</dt>
          <dd>
            Provides an interface that allows JavaScript code to call native libraries without requiring the development of an XPCOM component.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/DeferredTask.jsm" title="./DeferredTask.jsm">DeferredTask.jsm</a> {{gecko_minversion_inline("18.0")}}</dt>
          <dd>
            Run a task after a delay.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Dict.jsm" title="./Dict.jsm">Dict.jsm</a> {{gecko_minversion_inline("5.0")}}</dt>
          <dd>
            Provides an API for key/value pair dictionaries.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/DownloadLastDir.jsm" title="./DownloadLastDir.jsm">DownloadLastDir.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
          <dd>
            Provides the path to the directory into which the last download occurred.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/FileUtils.jsm" title="./FileUtils.jsm"><span style="font-weight: bold;">FileUtils.jsm</span></a> {{gecko_minversion_inline("1.9.2")}}</dt>
          <dd>
            Provides helpers for dealing with files.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Geometry.jsm" title="./Geometry.jsm">Geometry.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
          <dd>
            Provides routines for performing basic geometric operations on points and rectangles.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/ISO8601DateUtils.jsm" title="./ISO8601DateUtils.jsm">ISO8601DateUtils.jsm</a></dt>
          <dd>
            Provides routines to convert between JavaScript <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date" title="JavaScript/ Reference/Global Objects/Date"><code>Date</code></a> objects and ISO 8601 date strings.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/NetUtil.jsm" title="./NetUtil.jsm"><span style="font-weight: bold;">NetUtil.jsm</span></a></dt>
          <dd>
            Provides helpful networking utility functions, including the ability to easily copy data from an input stream to an output stream asynchronously.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/openLocationLastURL.jsm" title="./openLocationLastURL.jsm">openLocationLastURL.jsm</a> {{gecko_minversion_inline("1.9.1.4")}}</dt>
          <dd>
            Provides access to the last URL opened using the "Open Location" option in the File menu.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/PerfMeasurement.jsm" title="./PerfMeasurement.jsm">PerfMeasurement.jsm</a> {{fx_minversion_inline("4.0")}}</dt>
          <dd>
            Provides access to low-level hardware and OS performance measurement tools.</dd>
          <dt>
            <a href="/en-US/docs/Localization_and_Plurals" title="Localization and Plurals">PluralForm.jsm</a></dt>
          <dd>
            Provides an easy way to get the correct plural forms for the current locale, as well as ways to localize to a specific plural rule.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/PopupNotifications.jsm" title="./PopupNotifications.jsm">PopupNotifications.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
          <dd>
            Provides an easy way to present non-modal notifications to users.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Services.jsm" title="./Services.jsm">Services.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
          <dd>
            Provides getters for conveniently obtaining access to commonly-used services.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/source-editor.jsm" title="./source-editor.jsm">source-editor.jsm</a> {{fx_minversion_inline("11.0")}}</dt>
          <dd>
            The Source Editor is used by developer tools such as the Style Editor; this interface implements the editor and lets you interact with it.</dd>
          <dt>
            <a href="/en-US/docs/Mozilla/JavaScript_code_modules/XPCOMUtils.jsm" title="./XPCOMUtils.jsm">XPCOMUtils.jsm</a></dt>
          <dd>
            Contains utilities for JavaScript components loaded by the JS component loader.</dd>
        </dl>
      </td>
    </tr>
  </tbody>
</table>
<!-- languages({ "zh-cn": "zh-cn/Moduli_di_codice_JavaScript" }) -->
Revert to this revision