Skip to content

Dependency loader plugin. Loads dependencies (JS/CSS) and initializes plugins if related dom elements are available.

License

Notifications You must be signed in to change notification settings

Webastronaut/loadmodule

Repository files navigation

loadmodule

Dependency loader plugin (only 491 bytes minified). Loads plugin dependencies (JS/CSS) and initializes plugins if related DOM elements are available.

Needs basket.js and rsvp.js to work properly.

Example usage:

$(function() {

  /** Only if .fancybox is available loadModule will load the dependencies and invoke the callback
   * 
   * @param {array} Dependencies - JS or CSS files
   * @param {function} Callback - Gets invoked when all dependencies are loaded
   * @param {string} Unique - Used for cache busting; if you want loadmodule to fetch
   * the desired script from the server rather than from the local storage change this value
   */
	$('.fancybox').loadModule([
		'path/to/fancybox/jquery.fancybox.css', 
		'path/to/fancybox/jquery.fancybox.pack.js'
	],
	function() {
		$(this).fancybox();
	}, '1.0');
	
});

The code is available under MIT Licence, so do whatever you want to do with it.

About

Dependency loader plugin. Loads dependencies (JS/CSS) and initializes plugins if related dom elements are available.

Resources

License

Stars

Watchers

Forks

Packages

No packages published