Skip to content

Commit 91d5e05

Browse files
committed
Initial commit, puttin up the first readme + moving files over from
the new version of the requirejs-jquery example
0 parents  commit 91d5e05

File tree

11 files changed

+35398
-0
lines changed

11 files changed

+35398
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
www-build/

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Example of using jQuery and require.js with a shim config.
2+
====
3+
4+
This example shows one way to load jQuery and jQuery plugins with require.js. jQuery itself registers as an AMD module and can easily be loaded. Most plugins, however, does not register as AMD modules, and therefore, require.js doesn't know that the plugins need jQuery to be loaded.
5+
6+
The most important part is the app.js file, which specifies the [shim configuration](http://requirejs.org/docs/api.html#config-shim) for the plugins.
7+
8+
###File structure
9+
10+
- tools/
11+
build.js
12+
r.js
13+
14+
- www/
15+
app.html
16+
js/
17+
app.js
18+
lib/
19+
jquery.js
20+
jquery.alpha.js
21+
jquery.beta.js
22+
require.js
23+
app/
24+
main.js
25+
26+
###How to see it in action
27+
28+
Just serve up the www/ folder using any web server you'd like. If you have python installed, an easy way is to navigate into the www/ directory and type `python -m SimpleHttpServer`
29+
30+
###How to optimize ut using r.js
31+
To use the optimizer, you need [node.js](http://nodejs.org) or Java 6 installed. These instructions assume Node is being used. See the [Optimization page](http://requirejs.org/docs/optimization.html]for more information.
32+
33+
r.js and a build configuration is included in the tools/ folder. To build, navigate to tools/ and type `node r.js -o build.js`. You will find the built product in the www-build folder. If you serve that directory instead, you can see in the network panel of the web developer tools that the files aren't loaded separately any more.
34+

tools/build.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"appDir": "../www",
3+
"baseUrl": "js/lib",
4+
"dir": "../www-build",
5+
//Comment out the optimize line if you want
6+
//the code minified by UglifyJS
7+
"optimize": "none",
8+
9+
// point to the shim config we set up before
10+
"mainConfigFile": "../www/js/app.js",
11+
12+
"modules": [
13+
//Optimize the application files. jQuery is not
14+
//included since it is already in require-jquery.js
15+
{
16+
"name": "app"
17+
}
18+
]
19+
}

0 commit comments

Comments
 (0)