JQuery: connecting to a web page

Table of contents:

JQuery: connecting to a web page
JQuery: connecting to a web page
Anonim

jQuery is a Javascript library that focuses on how HTML, JavaScript and CSS technologies work together.

What jQuery can do

The library can work with the following list of tasks:

  • can access absolutely any element of the page object model (DOM) and perform complex manipulations with them;
  • event handling supported;
  • there is functionality for various graphic effects and animations;
  • simplified work with AJAX dynamic loading technology (a very important and extremely useful feature, but not about that now);
  • jQuery has a huge number of plugins of its own, the main function of which is to implement user graphical interfaces and user interaction with them.

Compressed and uncompressed versions of the library

Developers have several options for the script - one is compressed, the other is not. The full version is very convenient to use at the stage of coding and debugging (testing) web applications. The minimalized version, on the other hand, will have few useful advantages during debugging, but it loads much faster and takes up less space. So a compressed version of jQuery is appropriateuse already in the finished project, because it saves server traffic and disk space.

jquery connection
jquery connection

How to choose the right version of jQuery

There are several mainstreams in jQuery today - the 1.x, 2.x, and 3.x branches. Their striking difference is that, starting from the second version, any support for outdated browsers was discontinued, such as the browser from Microsoft Corporation - Internet Explorer, up to and including the eighth version.

This decision made it possible to reduce the physical volume of data in the library by ten percent and slightly optimize its work. However, there are still home and corporate computers in the world where the old Internet Explorer is installed as the main browser, although the percentage of these users does not exceed 3% worldwide. Therefore, it is up to you to support the outdated platform or not.

The developers of jQuery adhere to the principles of backward compatibility of versions. This means that code written for version 1.7 of the library will also work with version 1.8. But sometimes the developer company removes functions from jQuery that are not useful, so it's better to reread the documentation for the new version if you are going to upgrade.

In 2016, a new branch of jQuery was released. It was version 3.0, which became even faster and lighter than the old versions. Hacks were finally removed from it to implement some functions in outdated browsers, which allowed the library to be positioned as a modern and powerful development tool.

If yourthe project is already bound to some library, then first estimate the labor costs for the upgrade. If the benefit from the new version is worth it, feel free to start working. For all developers who are just starting to use the tool in their projects, it is advisable to start directly with the latest versions.

How to get started with jQuery

The first step is to connect jQuery. To do this, you need to directly download the library from the jquery.com developer resource, or from a mirror, and place the library on your web server.

Now let's do the actual jQuery connection to the web page. The connection of various scripts in the hypertext markup language is handled by the script tag. Connect jQuery with the following code:

jquery connection
jquery connection

This option is good for offline connection, but there are many other ways for server use.

Connect jQuery using cloud services

Google provides the Hosted Libraries service, using which anyone can connect a popular framework or library to their web application. To connect jQuery via Google Cloud Storage, use the string that matches the selected version in the following pattern:

how to include jquery library
how to include jquery library

The numbers in the versions column correspond to the version number that is available for installation and further work with it. To connect any of the intermediate versions, just copy itnumeric number in the connection string instead of the numbers specified in the example.

You can always view the list of current versions at:

developers.google.com/speed/libraries/jquery

If you don't trust Google for any reason, but still want to know how to get the jQuery library from a third-party trusted server, use the Microsoft repository.

include jquery library
include jquery library

jQuery is one of the best tools for easily creating animations on web pages. Once you realize the power of this tool, you will be very glad that you started to learn such a library.

Skeptics among students and developers believe that it is better to implement everything using a pure programming language, without using third-party libraries. But you need to understand that the jQuery file is only thirty-two kilobytes, and is most likely already in the cache of your user's browser if you include the script through Google. So don't be afraid to learn tools that make life easier for a developer. After all, for this we include the jQuery library - so as not to reinvent the wheel.

Recommended: