Permalink
Browse files

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

  • Loading branch information...
1 parent 0d3616e commit 8c792af26eb2e653302581f132aac266aca725d1 @eberhm committed Jan 30, 2013
Showing with 82 additions and 11 deletions.
  1. +10 −0 LICENSE
  2. +56 −1 README.md
  3. +16 −10 jq.js
View
10 LICENSE
@@ -0,0 +1,10 @@
+MIT License
+-----------
+
+Copyright (C) 2013 Guy Bedford
+
+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:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+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.
View
57 README.md
@@ -1,4 +1,59 @@
require-jq
==========
-Jquery require plugin for loading jquery plugins and extensions as per requirejs issue #658 suggestion
+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
+
+```javascript
+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](https://github.com/volojs/volo)(`npm install bower -g`):
+
+```bash
+bower install eherrera/require-jq
+```
+
+To allow the direct `jq!` usage, add the following [map configuration](http://requirejs.org/docs/api.html#config-map) in RequireJS:
+
+```javascript
+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
+-------
+* ~~Comprehensive CSS minification including style reduction~~
+* ~~LESS extension~~
+* Sprite compilation
+* Source maps?
+
+Suggestions always appreciated - feel free to post a feature request.
View
26 jq.js
@@ -1,10 +1,16 @@
-//jq require plugin.
-define('jq', {
- load: function (name, req, load) {
- req(['jquery'], function() {
- req([name], function (value) {
- load(value);
- });
- });
- }
-});
+/*
+ * jq! loader plugin
+ *
+ * Allows loading jquery prior to files depending on it.
+ */
+define([], function() {
+ return {
+ load : function(name, req, load) {
+ req(['jquery'], function() {
+ req([name], function (value) {
+ load(value);
+ });
+ });
+ }
+ };
+});

0 comments on commit 8c792af

Please sign in to comment.