Skip to content

Instantly share code, notes, and snippets.

@matdombrock
Created May 28, 2021 21:17
Show Gist options
  • Save matdombrock/12ec1e135cd49c3a1b01fc58aa5eb32e to your computer and use it in GitHub Desktop.
Save matdombrock/12ec1e135cd49c3a1b01fc58aa5eb32e to your computer and use it in GitHub Desktop.
NoJQ

We used to use jQuery for a lot of things.

We used to use jQuery for easily selecting elements. This has never been a problem IMO but its now we also have querySelector which is just as easy as jQuery.

jQ

$('.button')

Vanilla JS

document.querySelector('.button')

We used to use jQuery to wait for the DOM:

jQ

$(document).ready(() => {
	 //...
})

Vanilla JS

document.addEventListener("DOMContentLoaded", () => {
  //...
})

We used to use jQuery to add/remove CSS classes:

jQ

el.addClass('big')
el.removeClass('big')
el.toggleClass('big')

Vanilla JS

el.classList.add('big')
el.classList.remove('big')
el.classList.toggle('big')

We used to use jQuery to simplify AJAX requests. Now we can just use XMLHttpRequest().

A lot of frameoworks like Bootstrap ect used to use it. So a lot of people got accustomed to it from there. Bootstrap is/has dropped jQuery (I cant remember if that happened yet). Basically every modern framework is doing the same.

Having some knowledge of jQuery is great. It will come up from time to time for years into the future. Spending a ton of time learning it is not helpful going forward IMO.

More examples: https://flaviocopes.com/jquery/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment