My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Links

Source can be found at https://github.com/NJLaPrell/pluginloader

The Plugin Loader is a light weight function in the jQuery namespace for loading and tracking jQuery plugins, JavaScripts, and required CSS. Scripts can be loaded serially or asynchronously. Plugin Loader can be used to force dependencies by loading required scripts and CSS in each plugin. Because the scripts and CSS are tracked, nothing will be loaded more than once.

March 22, 2012

I regret to announce that I will no longer be contributing to the Plugin Loader project. My company was acquired late last year and in the integration process, it was decided that I will not be permitted to continue pursuing projects like this on my own time. I am permitted to continue my projects in an official capacity as an employee, however, the terms are not desirable.

I will leave the source on Github, but will be making no further contributions. If you have found this project useful, I strongly encourage you to fork it and continue its development.

November 5, 2011

Version 2.0.02 has been released to address a minor bug that was causing ".js" to be appended to libs and scripts.

August 11, 2011

I have officially released version 2 (2.0.01) with a few bug fixes. I have also updated it to take a string or array list of plugins as the argument (which causes it to use all default settings) or the parameter list. This should make it a bit more backwards compatible with calls that used the previous versions.

August 9, 2011

I have posted a very early release of version 2.0. All of the new features are in, but only minimal testing has been performed at this time.

Please Note: Version 2 now takes a single argument with all parameters, so the way it is called is different.

Installation (Version 2)

  • Update the jqDEFAULT variables at the top of the script as desired. These will be the defaults for each parameter when they are not passed in via the calling function.
  • Each plugin file name should be jquery.plugin name.js.
  • Each dependent CSS file should be named jquery. plugin name .css.

Now, simply load up the script to get started:

<script type="text/javascript" src="/jquery.pluginLoader.js"></script>

Usage (Version 2)

Usage is simple. The $.loadPlugins() function takes the following parameters: list - String for a single plugin or an array for multiple. path - (optional) The path where the called component(s) is/are stored. cache - (optional) Set to true to prevent the browser from caching the file. async - (optional) Set to true to call the files asynchronously or false to call them serially (use caution,this can cause the browser to freeze in some environments).

Load jQuery plugins "foo" and "bar."

$.loadPlugins({list:['foo','bar']});

Lets say foo has a corresponding CSS file. Update the foo plugin to call:

$.loadCSS({list:'foo'});

There is a small utility library called bob you need to load from the /libs/js/ folder:

$.loadLib({list:['bob.js'],path:'/libs/js/'});

July 18, 2010

The latest update now tracks which plugins are loaded automatically, without the need to add variables to each individual plugin script. Each plugin in the jqPlugins object is assigned a value of true if it loaded successfully, false if it did not, or undefined if the Plugin Loader never attempted to load it.

Installation

  • Update the script so that dOptions.path points to your jQuery plugin directory (You can also pass a different path when calling the $.loadPlugins() function).
  • Each plugin file name should be jquery.plugin name.js.

Now, simply load up the script to get started:

<script type="text/javascript" src="/jquery.pluginLoader.js"></script>

Usage

Usage is simple. The $.loadPlugins() function takes either a string (one plugin at a time) or an array, as well as an optional object to define additional options. We would load up jquery.foo.js and jquery.bar.js like this:

$.loadPlugins(['foo','bar']);

Options

An object with the following options can be passed as the second parameter:

  • path - Overrides the default path set in the cOptions object.
  • async - When set to false, causes the script to wait for the plugin to load before continuing to execute. When set to true, the script will load asynchronously. Default is false.

Tips

  • Check for the jqPlugin.myPlugin variable where myPlugin is your plugin name to see if the plugin is loaded. The value will be true if it successfully loaded, false if there was an error, or undefined if the plugin loader never attempted to load it.
  • Set the async option to true if nothing uses the plugin until after it will be loaded.
Powered by Google Project Hosting