jQuery: The Write Less, Do More JavaScript Library

*Updated. It has been tested with Internet Explorer 7, Mozilla Firefox 2 and Opera 8.

Syntax:

$.require('plugin(s)',[optional onload handler])
$.requirecss('cssfile(s)');

Load plugins without onload handler:

$.require('jquery.plugin1,jquery.plugin2');

Load plugins with onload handler:

$.require('jquery.plugin1,jquery.plugin2',function(){
    alert('hello world');
});

Load css files:

$.requirecss('cssfile1,cssfile2');

In the example above, it will load two plugin sequentially. It will load jquery.plugin2 only after jquery.plugin1. This way, if jquery.plugin2 requires jquery.plugin1, it can be successfully loaded without errors.

If you don't want to assign onload handler everytime you use require function, you can use requireComplete. The usage is almost the same as $(document).ready; Please not that, it will be run only after document is ready. Syntax:

  $(document).requireComplete(function(){//your code here});

Currently the base path is defaulted to require plugin folder for js files and require plugin folder + '/css' for css files. You can change it by assigning $.plg.jsBase to your js path and $.plg.cssBase to your css path.

*You don't have to put $(document).ready in your plugin. Currently, if one plugin fail to load, it will stop the queue.

download jquery-require.js