This approach references the jQuery file that lives on a CDN (another server)
The example below utilizes a jQuery-specific CDN found here
The integrity
and crossorigin
properties in the example ensure the file is delivered without any third-party manipulation
<html>
<head>
<title>Add jQuery using a CDN</title>
</head>
<body>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous">
</script>
<script src="js/app.js"></script>
</body>
</html>
Using a CDN like jQuery or Google also helps with loading time, and potential caching benefits.
A CDN is a collection of servers that can deliver content
A content delivery network (CDN) places files in different locations so that the person using your webpage can receive the nearest copy of it faster
Prevents your users’ browsers from downloading commonly used libraries(like jQuery) every time they visit your site
Use of CDNs increases page speed for highly trafficked sites
Click here for a nice overview of CDNs