How to install jQuery?

How to install jQuery?

Different ways to install jQuery

jQuery

There are several ways to install & use jQuery on your web site.

  1. Using jQuery with a CDN
  2. Download the jQuery library from jQuery.com
  3. Download jQuery using npm or Yarn
  4. Download jQuery using Bower

1. Using jQuery with a CDN

CDNs can host jQuery on servers across the globe.

jQuery hosted CDN : https://code.jquery.com/

Adding CDN code for minified jQuery lib.you can copy and past it into the head section on your HTML page.

<script src=”https://code.jquery.com/jquery-3.4.1.min.js” integrity=”sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=” crossorigin=”anonymous”></script>

Check out the demo on GitHub.

Other CDN links :

2. Download the jQuery library from jQuery.com

Two types of versions available for jQuery download.

  1. Production version: used with live website/apps as its compressed and minified. Github
  2. Development version: used for local server development as its uncompressed. Github

Go to the https://jquery.com/download/ and download the required version form the list.

3. Download the jQuery library from jQuery.com

jQuery is registered as a package on npm.Install the latest version of jQuery with the npm CLI command:

npm install jquery

As an alternative you can use the Yarn CLI command:

yarn add jquery

This will install jQuery in the node_modules directory. Within node_modules/jquery/dist/ you will find an uncompressed release, a compressed release, and a map file.

4. Download jQuery using Bower

jQuery is also registered as a package with Bower. You can install the latest version of jQuery with the command:

bower install jquery

This will install jQuery to Bower’s install directory, the default being bower_components. Within bower_components/jquery/dist/ you will find an uncompressed release, a compressed release, and a map file.

if you wish to install just the compressed jQuery file, you can install just that file with the following command:

bower install https://code.jquery.com/jquery-3.4.1.min.js

Find out browser support for the jQuery: https://jquery.com/browser-support/

This is it. Happy Coding.

Leave a Reply

Your email address will not be published. Required fields are marked *