How to connect the library ?

How to connect the library ?

Watch the video

How to connect the library?

jQuery is the most popular JavaScript-library, which is used for creating websites.Its share is about 89% of all libraries.It is used for easy interaction with JavaScript HTML-document and allows you to manipulate of DOM-elements page.

Then we'll show you how to connect the jQuery library to your site.

local files on the server

The easiest way to connect the library - a connection file from the server's local directory.

To do this:

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

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

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

Using CDN

Another of jQuery connectivity options to the site - the use of the CDN.

CDN - Content Delivery Network (Content Delivery Network) - way to download files from a remote server, which can speed up page load times due to the fact that the target file can be already stored (cached) on your computer.

To do this, you need to specify a link to an external API, for example:

  • & lt;script src = "// code jquery com / jquery-1.11.0 min js...." & gt; & lt; / script & gt ;.

In this case, use the link in the are many different servers, the most popular ones: jquery, Google and Cloudflare.

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

combination of local file and CDN

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

If you are interested in the development of sites, visit the Web Development on our website.