Part 2.2Why use jQuery?
As with all libraries on the web, there is a slight performance hit for adding more and more code to a site. Therefore, the benefits to adding a library such as jQuery need to outweight the disadvantages for it to be worthwhile.
Speed and efficiency
var elements = $("p"); console.log(elements);
var elements = document.querySelectorAll("p"); console.log(elements); //It could also be represented by: var elements = document.getElementsByTagName("p"); console.log(elements);
Of course, this is a minor saving at present because it's only used the one time. However, if it's used over and over again this can save some real time and effort. In terms of downloads, this is great. In terms of saving the developer time, this is much, much easier to remember.
Perhaps the main benefit of jQuery is that of cross-platform. jQuery aims to be platform independent and manages to include solutions that support different browsers. By example, Internet Explorer 8 has different methods for binding an event to a handler than those of Google Chrome. jQuery has just one implementation that wraps over both of these implementations so that code is not repeated for each browser. This is but one example of how jQuery deals with cross-platform development like this.