3
Small set of plugins for [RequireJS](http://requirejs.org). Some plugins may
4
also work on other AMD loaders (never tested it).
6
For more plugins check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins).
12
- **async** : Useful for JSONP and asynchronous dependencies (e.g. Google Maps).
13
- **font** : Load web fonts using the [WebFont Loader API](https://code.google.com/apis/webfonts/docs/webfont_loader.html)
14
(requires `propertyParser`)
15
- **goog** : Load [Google APIs](http://code.google.com/apis/loader/)
16
asynchronously (requires `async!` plugin and `propertyParser`).
17
- **image** : Load image files as dependencies. Option to "cache bust".
18
- **json** : Load JSON files and parses the result. (Requires `text!` plugin).
19
- **mdown** : Load Markdown files and parses into HTML. (Requires `text!`
20
plugin and a markdown converter).
21
- **noext** : Load scripts without appending ".js" extension, useful for
26
- **propertyParser** : Just a helper used by some plugins to parse
27
arguments (not a real plugin).
33
check the `examples` folder. All the info you probably need will be inside
34
comments or on the example code itself.
40
Put the plugins inside the `baseUrl` folder (usually same folder as the main.js
41
file) or create an alias to the plugin location:
46
//create alias to plugins (not needed if plugins are on the baseUrl)
47
async: 'lib/require/async',
48
font: 'lib/require/font',
49
goog: 'lib/require/goog',
50
image: 'lib/require/image',
51
json: 'lib/require/json',
52
noext: 'lib/require/noext',
53
mdown: 'lib/require/mdown',
54
propertyParser : 'lib/require/propertyParser',
55
markdownConverter : 'lib/Markdown.Converter'
59
//use plugins as if they were at baseUrl
64
'mdown!data/lorem_ipsum.md',
65
'async!http://maps.google.com/maps/api/js?sensor=false',
66
'goog!visualization,1,packages:[corechart,geochart]',
68
'font!google,families:[Tangerine,Cantarell]'
69
], function(awsum, foo, bar, loremIpsum){
70
//all dependencies are loaded (including gmaps and other google apis)
76
## Removing plugin code after build
78
[r.js](https://github.com/jrburke/r.js/blob/master/build/example.build.js)
79
nowadays have the `stubModules` setting which can be used to remove the whole
84
// will remove whole source code of "json" and "text" plugins during build
85
// JSON/text files that are bundled during build will still work fine but
86
// you won't be able to load JSON/text files dynamically after build
87
stubModules : ['json', 'text']
92
## Notes about the Markdown plugin
94
The Markdown plugin was created mainly to be used to compile the markdown files
95
into HTML during the build step, if you set `pragmasOnSave.excludeMdown=true`
96
it will remove the `Markdown.Converter.js` and `mdown.js` files from the build.
97
Example build settings:
106
mdown : 'lib/requirejs/mdown',
107
text : 'lib/requirejs/text',
108
markdownConverter : 'lib/Markdown.Converter'
116
If `excludeMdown=true` you won't be able to load markdown files dynamically
121
## Writing your own plugins
123
Check [RequireJS documentation](http://requirejs.org/docs/plugins.html) for
124
a basic reference and use other plugins as reference. RequireJS official
125
plugins are a good source for learning.
127
Also be sure to check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins).
133
[Miller Medeiros](http://blog.millermedeiros.com/)
139
All the plugins are released under the MIT license.