Home > simple-require

simple-require

Simple-require is a project mainly written in JavaScript, it's free.

A simple async javascript loader.

h1. simple-require

A simple asynchronous JavaScript and CSS loader.

h2. Features

  • JavaScript files are loaded asynchronously via XHR
  • Preserves execution order of scripts
  • Supports multiple file types:
    • JavaScript
    • Stylesheets

h2. Usage

simple-require provides one method wich is simply named require. It does what its name suggests, it requires a file. It is chainable. The actual loading is started by calling the now() function, which takes a callback that is called after loading all files.

A little example:


require("jquery-1.4.2.min.js")
    .require("first.js")
    .require("second.js")
    .require("style.css")
    .now(function() { 
    // Do something
});

h2. Thanks

Thanks goes to malt.js for the idea how to load css ( http://github.com/benvinegar/malt ).

h2. License

Copyright (c) Gregor Weckbecker <gregor feiner fug net> 2010

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Previous:WeaselDemo