In this section, we learn jQuery the installation of 0615b16fdaa7ea. In our actual project, if we want to use jQuery , we need to download the jQuery library first, and then import it into the web page to be used.

There are several ways to use jQuery

  • jQuery library from the official website, and then import it into the page.
  • Use commands to install jQuery , such as npm , bower commands.
  • From CDN Loading jQuery , such as from Google Loading jQuery .

jQuery download

We can jQuery download the official website of jQuery , download address is: https://jquery.com/download/ .

There are two versions of jQuery available for download:

  • Production version: used in the actual website, has been streamlined and compressed.
  • Development version: used for testing and development, uncompressed, readable code.

We download the corresponding version as needed. For example, I downloaded the jquery-3.5.1.min.js file, and then the downloaded file can be placed in the same directory as the web page, which is more convenient to use.

Then you can import the jquery file in the page, the import format is as follows:

<script src="jquery-3.5.1.min.js"></script>

Install jQuery using npm

jQuery is registered as a software package on npm npm CLI command to install the latest version of jQuery :

npm install jquery

Or use the Yarn command to install it:

yarn add jquery

Using these two methods to install jQuery , we can find an uncompressed release, a compressed release and a mapping file node_modules/jquery/dist/

Install jQuery with Bower

In addition to npm , jQuery also Bower , so we can also use the bower command to install the latest version of jQuery :

bower install jquery

This way, will jQuery installed Bower installation directory, the default is bower_components . We can find an uncompressed release, a compressed release and a mapping file bower_components/jquery/dist/

Use jQuery with CDN

If we don’t want to download and store jQuery , we can also CDN (content distribution network).

CDN is an intelligent virtual network built on the basis of the existing network, relying on edge servers deployed in various places, through the load balancing, content distribution, scheduling and other functional modules of the central platform, so that users can obtain the required content nearby and reduce network congestion. Improve user access response speed and hit rate.

For example, both Google and Microsoft servers jQuery . If we need to quote, we can do it like this:

  • Google quotes jQuery :

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  • Microsoft quotes jQuery :

    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.1.min.js"></script>

Summarize

Above we talked about jQuery . In the following learning chapters, we will download the jQuery library directly on the official website, and then use jQuery by referring to the page.


知否
221 声望177 粉丝

Skrike while the iron is hot.


« 上一篇
jQuery 简介
下一篇 »
jQuery语法

引用和评论

0 条评论