and students • In use at over 300 colleges & universities • Comprised of several Flex/AS3 apps • Simulations defined in XML • A single exam simulation might need to load up to 8,000 icons Thursday, February 7, 13
defining [JavaScript] modules such that the module and its dependencies can be asynchronously loaded. This is particularly well suited for the browser environment where synchronous loading of modules incurs performance, usability, debugging, and cross-domain access problems. Source: http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition “ Thursday, February 7, 13
loader plugins • Allows for loading non-JS dependencies asynchronously, e.g., HTML templates • Can be referenced in a module ID using special syntax: “loader-plugin-name!target-resource” Thursday, February 7, 13
in Node or Rhino • First runs dependency tree through require.js to determine order • Then concatenates source • Then minifies with UglifyJS Thursday, February 7, 13
• Keep code organized in logical units • Build re-usable components • Don’t pollute the global namespace • Easy to control scope Thursday, February 7, 13
modules with define() boilerplate • Some believe it should be a language-level change, instead of an external solution • Many HTTP requests unless using a build tool, such as r.js Thursday, February 7, 13