source: appstream-generator/contrib/setup/js_tmp/jquery/README.md @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 2.0 KB
Line 
1# jQuery
2
3> jQuery is a fast, small, and feature-rich JavaScript library.
4
5For information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).
6For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).
7
8If upgrading, please see the [blog post for 3.2.1](https://blog.jquery.com/2017/03/20/jquery-3-2-1-now-available/). This includes notable differences from the previous version and a more readable changelog.
9
10## Including jQuery
11
12Below are some of the most common ways to include jQuery.
13
14### Browser
15
16#### Script tag
17
18```html
19<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
20```
21
22#### Babel
23
24[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.
25
26```js
27import $ from "jquery";
28```
29
30#### Browserify/Webpack
31
32There 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...
33
34```js
35var $ = require("jquery");
36```
37
38#### AMD (Asynchronous Module Definition)
39
40AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).
41
42```js
43define(["jquery"], function($) {
44
45});
46```
47
48### Node
49
50To include jQuery in [Node](nodejs.org), first install with npm.
51
52```sh
53npm install jquery
54```
55
56For 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.
57
58```js
59require("jsdom").env("", function(err, window) {
60        if (err) {
61                console.error(err);
62                return;
63        }
64
65        var $ = require("jquery")(window);
66});
67```
Note: See TracBrowser for help on using the repository browser.