How to connect the jQuery library

How to connect the jQuery library

The jQuery libraries can be connected in several ways, they are open and are in free access. Many developers choose this library, as it saves time significantly, and most importantly, has already been tested from most users. It frees them from a long download of the site, because many still use mobile modems, whose speed is quite low. To begin with, it is better to figure out the difference of versions and types of libraries, as they may differ significantly. Go to jQuery official websiteTo start viewing.



1
Which jQuery libraries are

If you look at the links of the official site, you will see that libraries differ in such keywords:

  • Compressed is compressed libraries, they take less space, but their code is a little more difficult to implement;
  • Uncompressed, on the contrary, downloads a larger library file, it is not compressed.

Of course, the libraries differ in versions. It is better to download the latest.



2
How to connect jQuery: first way

The most popular way implies the presence of a separate hosting, where you place the library. Go to the JQuery official website, find the orange button "Download jQuery" and click on it.

Next, select the version and type of library referred to in the first paragraph of the article. See what name the file you downloaded. You need to put it in a convenient place in the directories of the site, and then register such a small code:

As you can see, this is a standard HEAD code with a library file location script. Please note that the file name is better not to change, so you will always see which version of jQuery is connected. You can add the location of the file in the HEAD code to the Soviets. If you position the library under all the main elements (header, text itself), then provide more convenient use of the site to users who have a slow connection.

Thus, it is better to place the script, as in the screenshot below:

3
How to connect jQuery through CDN hosting

This is especially true if you only learn, or want to save a place on your hosting. You do not need to allocate memory for the library, as they will be fully stored on third-party sources. The most popular CDN today:

Consider the Google Service. Go to the site and find the code you need, just copy it. Connection occurs insertion code into your source. A huge plus is caching, many users of the library from Google are already covered, so they do not have to wait for the download if the Internet speed is low.

Google CDN is convenient for its division into so-called snippets, you can only determine the desired and copy to your code.

The inserted code will look like this:

4
Is it possible to connect jQuery on WordPress

If you are engaged in the development of a site for WordPress, everything becomes even easier, as the libraries appear automatically immediately after the code:

\u003c? PHP. wP_Head.(); ?>
The library will appear inside the HEAD block. This minus will be an outdated version of jQuery, because on the WordPress engine it is not updated in a timely manner. If you need fresh, then do the following:
Put the code that first disables the libraries, and then connects them from Google.

Add a comment

Your e-mail will not be published. Mandatory fields are marked *

close