Jquery require plugin for loading jquery plugins and extensions as per requirejs issue #658 suggestion
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
component.json
jq.js
manifest.json

README.md

require-jq

Jquery require plugin for loading jquery plugins and extensions as per requirejs issue #658 suggestion

Overview

Allows the construction of scripts that can require the Jquery library (eg: plugins), using the simple RequireJS syntax. This plugin comes out from the need of resolving at runtime the dependency for certain files of jquery lib. As per

define(['jq!path/to/jquery/plugins/myplugin'], function() {
  //code that requires the plugin: path/to/jquery/plugins/myplugin
});

//you can also use an URL
define(['jq!http://www.mysite.com/path/to/jquery/plugins/myplugin.js'], function() {
  //still should work
});

Installation and Setup

Download the require-jq folder manually or use bower(npm install bower -g):

bower install eberhm/require-jq

To allow the direct jq! usage, add the following map configuration in RequireJS:

map: {
  '*': {
    'jq': 'require-jq/jq' // or whatever the path to require-jq is
  }
}

Use Cases and Benefits

Motivation

The use case for require-jq came out of a need to manage non amd jquery dependant files (i.e. most jquery plugins) at runtime and not at shim config. The main reason for that is that using shim config for this task in large projects would grow the config file in size and comlexity quickly. With this plugin the declaration of the dependency can be put into the require call therefore resolve new dependencies without the need for a extra shim config. When writing a large dynamic application, the number of jquery plugins trends to grow, it can be beneficial to inject the plugin only if needed instead of at page load.

Roadmap

Suggestions always appreciated - feel free to post a feature request.