Code Monkey home page Code Monkey logo

alameda's Introduction

#alameda

An AMD loader, like requirejs, but with the following implementation changes:

  • Uses promises underneath, via prim.
  • Targets "modern" web browsers that implement script.onload standardized behavior.
  • Assumes browser support for Array.isArray, array extras, ES5 features.
  • Does not support a couple of less-used APIs (see tests section below)

These changes means alameda is around 30% smaller than requirejs, 4148 bytes vs 6036 bytes, minified+gzipped sizes. If you need a basic promise module, alameda comes with one that can be injected as a module, so in that case you also save some over size for your project.

Browser support:

  • Firefox
  • Chrome
  • Safari, WebKits in iOS and Android
  • IE 10+

So, no IE 6-9, and probably not NetFront browsers, like the PS3. IE 9 had a bug where onload did not follow script execution. That bug was fixed in IE 10. If that fix was backported to IE 9, then alameda would work in IE 9.

You can continue to use requirejs and the r.js optimizer for other scenarios. The r.js optimizer works well with alameda-based projects.

API

alameda supports the requirejs API. It even declares requirejs, to make passing the requirejs tests easier. alameda also has a good chance of becoming requirejs in a far-future requirejs version.

One config option alameda exposes that is not part of the requirejs API is the primId config option. You have the option to inject alameda's private prim implementation as a module with the ID given in primId:

require.config({
    primId: 'prim'
});

require(['prim'], function (prim) {
    // prim here is the prim version built
    // in to alameda.js, no need to deliver
    // a separate prim module.
})

With prim, you get a basic promises a+plus compliant implementation with .then() chaining.

Running tests

The tests are pulled from almond and requirejs. All tests should be served through a local web server, as the text loader plugin is used for some tests, and some browsers restrict local XHR usage when the files are served from a file:// URL.

Bundled tests

To run the tests that are just part of this repo, open tests/index.html in a web browser.

requirejs tests

To run the requirejs tests, first make sure the following projects have been cloned and are siblings to the the alameda repo:

Then do the following:

  • symlink alameda.js to require.js
  • ./copyrequirejstests.sh

requirejs tests that do not pass

  • require.undef()-related tests.
  • onResourceLoadNestedRequire: depends on implementing requirejs.onResourceLoad hook used for builds/some third party tools. This API is not required for normal module loading. Use the r.js optimizer for tools that need this API.

How to get help

alameda's People

Contributors

jrburke avatar

Watchers

 avatar  avatar  avatar

Forkers

muskanmahajan37

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.