Adding jQuery

The jQuery Library is essentially, just a large file of JavaScript functions, objects, and methods, all designed to make doing tasks in JavaScript faster and easier, hence the jQuery slogan "write less, do more."

However, this convenience comes at cost. The browser does not understand jQuery natively, and so it is required to add jQuery Library. This is accomplished just like adding any other JavaScript file with the <script> tag.

The most common way to add jQuery Library is through the use a Content Delivery Network (CDN). The official jQuery CDN can be found on https://code.jquery.com and can be added to an HTML file like so:








 






<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>jQuery</title>
  <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</head>
<body>
  
</body>
</html>

Note

The jQuery Library must be added to the page before any other JavaScript that might rely on jQuery.