scratch – Blame information for rev 126

Subversion Repositories:
Rev:
Rev Author Line No. Line
58 office 1 # jQuery
2  
3 > jQuery is a fast, small, and feature-rich JavaScript library.
4  
5 For information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).
6 For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).
7  
8 ## Including jQuery
9  
10 Below are some of the most common ways to include jQuery.
11  
12 ### Browser
13  
14 #### Script tag
15  
16 ```html
17 <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
18 ```
19  
20 #### Babel
21  
22 [Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively.
23  
24 ```js
25 import $ from "jquery";
26 ```
27  
28 #### Browserify/Webpack
29  
30 There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this...
31  
32 ```js
33 var $ = require("jquery");
34 ```
35  
36 #### AMD (Asynchronous Module Definition)
37  
38 AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).
39  
40 ```js
41 define(["jquery"], function($) {
42  
43 });
44 ```
45  
46 ### Node
47  
48 To include jQuery in [Node](nodejs.org), first install with npm.
49  
50 ```sh
51 npm install jquery
52 ```
53  
54 For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes.
55  
56 ```js
57 require("jsdom").env("", function(err, window) {
58 if (err) {
59 console.error(err);
60 return;
61 }
62  
63 var $ = require("jquery")(window);
64 });
65 ```