How to add jQuery from a CDN?
Adding jQuery to a web page from a Content Delivery Network (CDN) is a common practice because it allows you to use the speed and reliability of a third-party server.
Choose a jQuery CDN
Select a CDN provider that hosts jQuery. Common choices include Google, Microsoft, and jQuery's official CDN. For this example, we'll use the Google CDN.
Include jQuery in Your HTML
In the <head> section of your HTML document, add a <script> tag with the CDN URL.
Specify the jQuery Version
In the src attribute of the <script> tag, you can specify the version of jQuery you want to use. In the example above, we've used version 3.5.1. You can replace this version number with the one you need.
In this example, we use $(document).ready() to ensure that the code inside it is executed only after the document has fully loaded. Then, we use the $ symbol to access jQuery functions, such as $("#myButton") to select the button with the ID "myButton" and .click() to attach a click event handler.
If you wish to use jQuery CDN other than Google or Microsoft hosted jQuery library, you might consider using this and ensures uses the latest version of jQuery: