Skip to content

A simple AMD loader plugin for loaders like RequireJS that makes it easier to set up plugins for libraries like jQuery.

License

Notifications You must be signed in to change notification settings

rjgotten/require-plug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plug

A simple AMD loader plugin for loaders like RequireJS that makes it easier to set up plugins for libraries like jQuery.

This allows you to load additional plugin scripts that depend on a master library script before the loading of the master script is completed. In this way you can finish plugging the library before it is used.

Usage

plug only works with AMD loaders that support module config, like RequireJS 2.0.

First, set up a module config for plug and list out the plugins for your master library.

require.config({
	config: {
		plug: {
			"jquery": [ "jquery.ui", "jquery.validate" ]
		}
	}
});

In this example, the jQuery library will be plugged with both jQuery UI and a forms validation plugin.

Then, to load your master library along with all of its plugins, use the plug! loader prefix ID:

define(["plug!jquery"], function ( $ ) {
	// jQuery will have been plugged with jQuery UI and the validation
	// plugin by the time this function is called.
    
	$( "#popup-form" )
		.validate()
		.dialog();    
});

About

A simple AMD loader plugin for loaders like RequireJS that makes it easier to set up plugins for libraries like jQuery.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published