Adding jQuery via CDN
CDN stands for Content Delivery Network. It hosts libraries like jQuery on multiple servers worldwide, allowing faster and more reliable loading by serving the file from a nearby location.
You can include jQuery in your HTML by adding the following <script> tag before the closing </body> tag:
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
This loads the latest stable minified version of jQuery (3.7.1) from the official jQuery CDN.
<!DOCTYPE html>
<html>
<head>
<title>jQuery CDN Example</title>
</head>
<body>
<button id="clickMe">Click Me</button>
<!-- jQuery from CDN -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
$(document).ready(function() {
$("#clickMe").click(function() {
alert("Button Clicked!");
});
});
</script>
</body>
</html>
- Faster load time due to geographic distribution
- Improved caching—may already be cached in the browser
- Reduces your own server bandwidth
- Easy to integrate with no setup required


