How to connect the library?

Watch the video

How to connect the library?

jQuery is the most popular JavaScript library used to create websites. Its share is about 89% of all used libraries. It is used for conveniently interacting JavaScript with an HTML document and allows you to manipulate DOM elements of a site page.

Next, we will explain how to connect the jQuery library to your site.

Local file on server

The easiest way to connect a library is to connect a file from the local server directory.

For this you need:

  1. Download the file with the library from the official site. On the site you can find the latest version of the library.
  2. Create a directory in the root folder of the site where our library will be stored, for example, mySite / JS / jQuery, and copy the downloaded files into it.
  3. Connect the file to the site. To do this, in the header <head> insert the following line:
    • <head>
    • <script src="/js/jquery/ jquery.js"></script>
    • </head>

In fact, we just connected an external script. If your site uses other scripts, they should be connected after jQuery. The library is ready to use.

This method of connection is the most reliable, but it slows down the page loading somewhat.

Using CDN

Another option for connecting jQuery to a site is using a CDN.

CDN - Content Delivery Network - a way to download files from a remote server, which allows you to increase the speed of loading the page due to the fact that the desired file can already be saved (cached) on the user's computer.

To do this, you must specify a link to the external API, for example:

  • <script src = "//"> </ script>.

In this case, the link to was used. There are many different servers, the most popular of them: jquery, Google and Cloudflare.

This method will increase the page loading speed, but at the same time make your site dependent on the operation of other servers.

Combination of local file and CDN

The best option would be a combination of the two presented methods. First, the library file is loaded from the CDN, and if it is not loaded, the local file is loaded from the server.

Related news

How to connect the library image, picture, imagery

How to connect the library 84

How to connect the library 8

How to connect the library 64

How to connect the library 71

How to connect the library 61

How to connect the library 2

How to connect the library 26

How to connect the library 37