Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

First production ready commit. Still needs some wording in MD file

  • Loading branch information...
commit 8c792af26eb2e653302581f132aac266aca725d1 1 parent 0d3616e
Eber Herrera authored January 30, 2013
10  LICENSE
... ...
@@ -0,0 +1,10 @@
  1
+MIT License
  2
+-----------
  3
+
  4
+Copyright (C) 2013 Guy Bedford
  5
+
  6
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  7
+
  8
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  9
+
  10
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57  README.md
Source Rendered
... ...
@@ -1,4 +1,59 @@
1 1
 require-jq
2 2
 ==========
3 3
 
4  
-Jquery require plugin for loading jquery plugins and extensions as per requirejs issue #658 suggestion
  4
+Jquery require plugin for loading jquery plugins and extensions as per requirejs issue #658 suggestion
  5
+
  6
+Overview
  7
+--------
  8
+
  9
+Allows the construction of scripts that can require the Jquery library (eg: plugins), using the simple RequireJS syntax.
  10
+This plugin comes out from the need of resolving at runtime the dependency for certain files of jquery lib. As per
  11
+
  12
+```javascript
  13
+define(['jq!path/to/jquery/plugins/myplugin'], function() {
  14
+  //code that requires the plugin: path/to/jquery/plugins/myplugin
  15
+});
  16
+
  17
+//you can also use an URL
  18
+define(['jq!http://www.mysite.com/path/to/jquery/plugins/myplugin.js'], function() {
  19
+  //still should work
  20
+});
  21
+```
  22
+
  23
+Installation and Setup
  24
+----------------------
  25
+
  26
+Download the require-jq folder manually or use [bower](https://github.com/volojs/volo)(`npm install bower -g`):
  27
+
  28
+```bash
  29
+bower install eherrera/require-jq
  30
+```
  31
+
  32
+To allow the direct `jq!` usage, add the following [map configuration](http://requirejs.org/docs/api.html#config-map) in RequireJS:
  33
+
  34
+```javascript
  35
+map: {
  36
+  '*': {
  37
+    'jq': 'require-jq/jq' // or whatever the path to require-jq is
  38
+  }
  39
+}
  40
+```
  41
+
  42
+Use Cases and Benefits
  43
+----------------------
  44
+
  45
+### Motivation
  46
+
  47
+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
  48
+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.
  49
+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.
  50
+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.
  51
+
  52
+Roadmap
  53
+-------
  54
+* ~~Comprehensive CSS minification including style reduction~~
  55
+* ~~LESS extension~~
  56
+* Sprite compilation
  57
+* Source maps?
  58
+
  59
+Suggestions always appreciated - feel free to post a feature request.
26  jq.js
... ...
@@ -1,10 +1,16 @@
1  
-//jq require plugin.
2  
-define('jq', {
3  
-    load: function (name, req, load) {
4  
-        req(['jquery'], function() {
5  
-            req([name], function (value) {
6  
-                load(value);
7  
-            });
8  
-        });
9  
-    }
10  
-});
  1
+/*
  2
+ * jq! loader plugin
  3
+ *
  4
+ * Allows loading jquery prior to files depending on it.
  5
+ */
  6
+define([], function() {
  7
+  return {
  8
+      load : function(name, req, load) {
  9
+          req(['jquery'], function() {
  10
+              req([name], function (value) {
  11
+                  load(value);
  12
+              });
  13
+          });
  14
+      }
  15
+  };
  16
+});

0 notes on commit 8c792af

Please sign in to comment.
Something went wrong with that request. Please try again.