To start working with jQuery, you must include a jQuery JS file on your web page. There are two ways to use a jQuery file on your web page; either you can download it from the official jQuery website or link directly using CDN services.
How to Use jQuery
- Download the latest jQuery file from the official jQuery website.
- Use jQuery directly from free CDN services like jQuery CDN, Google Hosted Libraries, etc.
jQuery Download File
- Compressed and uncompressed copies of jQuery files are available to download; you can download the production compressed version; if you don't want to edit it later.
- To use jQuery by using the downloaded file, you need to add the jQuery js file to your webpage by using HTML
<script>
tag.
Example:
<script src="jquery.min.js"></script>
jQuery CDN
jQuery is already hosted on CDN, so you can use it directly without downloading, and it is also the best solution to save server bandwidth by using CDN services.
Example:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>