10% Getting Started
We've got the basics down, now it's time to move on to actually studying jQuery. It all starts with including the library. And even at this stage we can go several routes:
Download jQuery from the project's home page https://jquery.com/ and place it right next to our HTML page (I recommend downloading the development version β it's always fun to dig through the source code :):
<script type="text/javascript" src="js/jquery.js"></script>This approach is great for working offline or when you have a really slow internet connection. Pay special attention to the path β scripts are collected in a separate folder "
js". And this is no accident, you need to train yourself to keep things organized.Use a CDN. I prefer the service from Google, but there's also Microsoft, as well as the universal https://cdnjs.com/ and https://www.jsdelivr.com/ β many of them also host lots of popular plugins, which is pretty nice of them.
There's also a CDN provided by the jQuery developers themselves, but it's far from as advanced as the others, and from my experience it's had stability issues, so be careful when working with it β https://releases.jquery.com/
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>CDN is a pretty clever thing β when you request the jQuery library this way, you'll get HTTP headers back saying that this file won't "expire" for a whole year.
If you request the file at
jquery@3.7/dist/jquery.min.js, you'll get the latest available version from the 3.7.x branch β at the time of writing, that was version 3.7.1, and the headers will indicate that this file will be cached on the browser side for 7 days.Same situation with the request
jquery@3/dist/jquery.min.jsβ it will return the latest available version from the 3.x.x branch, cached for 7 days.Using the NPM package manager, install the library we need. This package manager lets you install all sorts of libraries and packages β there are way too many to keep track of.
Why do I mention this package manager? Well, maybe one of you will be curious enough to figure out how to work with it on your own :)
Last updated