# jQuery introduction
# What is jQuery?
- jQuery is a lightweight JavaScript API/library
- "Write less, do more": with jQuery, you can write a lot of common tasks that require many lines of native (also called: vanilla) JavaScript code into a single line of jQuery code
- The jQuery library contains the following features:
- DOM manipulation
- Event handlers
- Basic effects and advanced animations
- AJAX requests
- For almost every task you can imagine, there is a jQuery plugin available (form validation, image galleries, ...)
- You can find more information about jQuery at the official jQuery website (opens new window)
# Is jQuery still relevant?
- jQuery's relevance is a topic of debate among web developers, as
- Javascript has become more mature as a language
- modern browsers like Chrome and Firefox correctly/consistently implemented JavaScript (in contrast to Internet Explorer)
- modern & advanced JavaScript frameworks (AngularJS, React, Vue) became increasingly popular
- On the other hand, jQuery is still used
- in more than 75% of the top 1 million websites (according to BuiltWith (opens new window))
- in a lot of CSS frameworks, like Bootstrap 4.x
- in our follow-up courses Web Applications in PHP (opens new window) and Cordova (opens new window)
# How to use jQuery?
- Add a
<script>
tag referring to the jQuery library just before the closing</body>
tag. Thesrc
attribute of this<script>
tag may refer to- a CDN link to the latest jQuery library
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
or
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
- Examples: Bootstrap course page, Expect More Food exercise
- a locally stored version of the latest jQuery library (copied in the Gulp task 'copy-js' from the node_modules folder, in which jQuery is installed as a devDependency using npm)
<script src=".../jquery.min.js"></script>
- Examples: Bootstrap-Sass example, repo of the group project, repo with the ES6/jQuery examples and exercises
- a CDN link to the latest jQuery library
READING TIPS
- Efficiƫnt scripten met jQuery 3.x (opens new window) (in Dutch)
- jQuery Cheat Sheet (opens new window)
- jQuery Tutorial (opens new window)
- From jQuery to vanilla JavaScript