Javascript vs jquery

First thing first Javascript is a programming language and Jquery is a Javascript library.
That means Jquery is a set of functions written in Javascript to easy up things. So wen you use Jquery you
instantly use javascript . Let me clear things up with some examples:

/* Select something from the DOM: */
    // jQuery
    $('selector');
    
    // Native Javascript
    document.querySelectorAll('selector');

/*Wrap an HTML structure around each element:  */

// jQuery
$('.inner').wrap('<div class="wrapper"></div>');

// Native
Array.prototype.forEach.call(document.querySelectorAll('.inner'), (el) => {
  const wrapper = document.createElement('div');
  wrapper.className = 'wrapper';
  el.parentNode.insertBefore(wrapper, el);
  el.parentNode.removeChild(el);
  wrapper.appendChild(el);
});

So, as you can see Jquery needs less writing wen doing complex things but Jquery is a pretty large file and needs to be parsed.
I recommend to use Jquery only wen doing very complex things, if you only need to add some click events on some elements it’s pretty easy to use pure JavaScript.

1 Like