How to download and load jQuery

I will explain how to load jQuery, which is a JavaScript library. With jQuery, you can operate HTML tags / CSS and ajax communication with a short description.

Download jQuery

This is the usual way to download and use jQuery.

jQuery download page

The latest version on February 26, 2020 is jQuery Core 3.4.1. Right-click on the link called "minified" in jQuery Core 3.4.1 and save it as a name. "Minified" is a miniaturized jQuery.

Place jQuery in the document root

Let's put jQuery in the document root of the server. Document roots are different for each web server and web framework. Place jQuery in the document root of your environment.

For the sake of clarity, place jQuery in a directory called js.

js / jquery-3.4.1.min.js

Loading jQuery

Let's load jQuery. Let's load jQuery in the HTML header.

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

Let's write a code that displays "Hello, World!" To make sure jQuery is loaded correctly.

<script src = "/ js / jquery-3.4.1.min.js"> </script>
<script>
  $(function () {
    alert ('Hello, World!');
  });
</script>

When "Hello, World!" Is displayed, jQuery has been loaded successfully.

Load jQuery using CDN

How to load jQuery using a CDN without downloading. CDN is a method to load jQuery provided by other sites on your own site.

<script src = "https://code.jquery.com/jquery-3.4.1.min.js"> </script>

In the introduction to HTML / CSS, I will introduce how to download jQuery as a standard method for creating websites, and in the sample code, I would like to utilize the CDN so that I can try it by copy and paste.

Associated Information