All you need to start using require.js in the browser.
The r.js file allows you to run the optimizer as well as run modules in Node, Rhino, Nashorn or xpcshell.
If you are running in Node, and want to use npm to install this file via npm, see the Use with Node page for more information.
For information on its use, as well as how to get the JAR files to run it under Rhino/Nashorn, see the r.js README.
These are useful loader plugins that have the same license terms as require.js itself. Download the plugin file and place it as a sibling to your "data-main" main.js script.
Load text files and treat them as dependencies. Great for loading templates. The text strings can be inlined in an optimized build when the optimizer is used.
Wait for the DOM is ready. Useful for pausing execution of top level application logic until the DOM is ready for querying/modification.
Load files written in CoffeeScript. With this plugin, it is easy to code in CoffeeScript in the browser, it can participate in the optimizer optimizations, and it works in Node and Rhino/Nashorn via the RequireJS adapter. This is the best way to do cross-environment, modular CoffeeScript. The project home has more information on how to install and use it.
Load string bundles used in internationalization (i18n) that are made up of separate country/language/locale-specific bundles.
Small updates to the optimizer.
Just updates to the optimizer, mainly an update to UglifyJS 2.8.29.
Just an update to the optimizer to use Esprima 4.0.
Optimizer updates for esprima and uglify-js dependencies, and a fix for map config used by plugins in builds. require.js fix for calling plugin normalization more than once. alameda 1.1.1 also fixes calling plugin normalization more than once.
Fixes an issue that prevented the 2.3.x optimizer from running in Java's 8+'s jjs. There was a change in require.js and a change in the r.js optimizer.
Only one change from 2.3.0, and it is in the optimizer. It fixes how the bundled uglifyjs declares the addFile function. Without the fix, it causes an error in Node 0.10/0.12. Newer versions of Node are not affected.
The way dependencies are found for the sugared syntax changed slightly in #1582. It is now faster and should catch more legitimate dependency cases. You should not notice any negative consequences to the change, but given how important that mechanism is, it was best to rev the minor version to 2.3. The r.js optimizer also handles larger directory changes better. If you are using 2.2, you are encouraged to update to 2.3.
alameda was also updated to 1.1.0 to include the same dependency searching change as requirejs 2.3.
Full list of changes:
More details on the higher level motivations for the 2.2 release.
Full list of changes:
The main issue: a change in 2.1.21 of require.js created an extraneous global. While jshint is used in the repo, it was not properly configured to catch that issue, but it is now. Only the require.js loader changed. No r.js optimizer-specific bug fixes, but it uses require.js as a dependency.
Full list of changes:
Main changes in the r.js optimizer: updates to the Esprima and UglifyJS dependencies. For require.js: fixes a couple of error conditions.
Full list of changes:
The main fixes: a fix in require.js to allow out of order define calls in a built file, and an optimizer fix to detect another UMD pattern and to skip looking at its internal structure.
Full list of changes:
A new onNodeCreated hook in require.js that will allow extending requirejs to support Subresource Integrity (SRI). Updates for esprima and uglifyjs2 in the optimizer.
Full list of changes:
The notable changes are in the r.js optimizer:
Full list of changes:
The notable changes are in the r.js optimizer: an update to Esprima 2.1.0 for dependency tracing, and a fix around "use strict" processing that should help some loader plugins or build scenarios that were using React.
Full list of changes:
The notable changes are in the r.js optimizer:
!function(a) {...`
. If you use the UMD node package to generate your UMD wrappers, upgrade to umd@3.0.0 or later to get full compatibility with the r.js optimizer.Full list of changes:
Mainly fixes a regression from 2.1.14 in the r.js optimizer where some define() calls were not found. The most common manifestations of the bug would be either an extra define('jquery', function(){})
in the build output or namespaced builds not working. The fixes for 2.1.15 are just in the optimizer. Full list of changes:
A couple more regression fixes for 2.1.12. One to fix nested plugin ID normalization, like "pluginA!pluginbB!resource", and one for the optimizer incorrectly detecting UMD wrapped code.
Version 2.1.12 regressed around ID normalization. 2.1.13 fixes that regression, and it is recommended that you do not use 2.1.12, but use 2.1.13 instead.
Just a bug fix/maintenance release. Full list of changes:
Some bug fixes, with the most notable addition is an optimizer option, wrapShim
. This will wrap shimmed dependencies in a define() call so that they work better after a build when their upstream dependencies are also AMD modules with dependencies.
The most notable case is probably when using an AMD-aware version of Backbone, but using shim config for scripts that depend on Backbone. If this is your use case, then setting wrapShim: true
in the optimizer config will likely fix any post-build problem you might see. More details in the bug ticket.
Full list of changes:
Mainly a maintenance release, and improves some cases when reusing code that was installed via npm. There are two new config options for the loader too:
example.js
and example
interchangeably. Setting this config option to true will accommodate that style. almond 0.2.9+ also supports this option.And for the optimizer, the mainConfigFile option can now take an array of file paths that have configs in them. Later values take precedent over earlier values.
Full list of changes:
Full list of changes:
Mainly a maintenance release to fix bugs. There is a new skipDataMain option in require.js to avoid the data-main work, which can be useful for browser extensions that should let the main content page's requirejs handle the data-main.
A small release to fix an optimizer issue with parsing config calls for modifications.
The main changes for this release:
Full list of changes:
Source map support has been expanded. Previously, it was just supported for going from minified, bundled code to the unminified, bundled code. If optimize: 'uglify2'
is used, it will now go back to the separated, unbundled files.
Source map support is still considered experimental though, so you may find bugs. If you find one, file an r.js issue, ideally with a test case.
Full list of changes:
Biggest change is support for running the optimizer and loading AMD modules in xpcshell. Other than that, just a maintenance release.
Full list of changes:
Quick release for a bug that slipped in the 2.1.3 release in the r.js optimizer. So even though require.js now has a 2.1.4 version, it is the same as 2.1.3, and the optimizer is the same as 2.1.3 except for this one fix:
Without this fix, in some cases 2.1.3 would insert "undefined" in some optimized CSS files, making them unusable.
Maintenance release. A change that may be noticeable:
require.toUrl() now correctly generates URLs for string values passed to it without an extension. Previous versions of toUrl() would append a ".js" extension automatically. If you relied on that behavior, when you update to 2.1.3, then you may need to do a code change to append the .js extension yourself:
require.toUrl('some/value') + '.js'
The text plugin has been updated to also work with this change, so if you want to generate non-extension paths for text resources, be sure to upgrade to to the 2.0.4 version of text.js.
Normal use of toUrl with a value that has an extension continues to work the same.
Full list of changes:
The big changes for this release are in the optimizer:
Full list of changes:
See the Upgrading to 2.1 page.
The main focus of this release was cleaning up some rough edges after switching to esprima for all module parsing. Most notably, findNestedDependencies should work correctly again. The bundled UglifyJS was updated to 1.3.3 too.
Complete list of fixes:
Probably the most notable changes:
Complete list of fixes:
Same as 2.0.3, but rolled back a change in r.js that caused a logging error.
Small bug fixes to:
Small bug fixes to:
Main purpose of the release is to fix a regression in 1.0.5 where the optimizer's "dir" config option was not applied correctly when passed on the command line.
The other notable change: the optimizer now supports onBuildRead and onBuildWrite functions that are called when JS modules are read or written for an optimized build layer. This allows doing some regexp work to modify their contents.
Small bug fixes to:
Small bug fixes to:
Small bug fixes to:
Small bug fixes to:
Small bug fixes to:
Just small bug fixes related to:
Detailed list of changes for require.js and the r.js optimizer: