jQuery vs JS
Al final quan el Javascript hagi evolucionat prou, el jQuery ja no serà necessari.
Però he de dir que jQuery força al programador a programar d’una manera elegant i ordenada. Tant de bo quan jQuery no faci falta es continuï utilitzant la mateixa elegància.
Vegeu més exemples a: https://css-tricks.com/now-ever-might-not-need-jquery/?utm_source=frontendfocus&utm_medium=email
jQuery:
var $elem = $(".someClass") //select the element
$elem.remove(); //remove the element
Without jQuery:
var elem = document.querySelector(".someClass"); //select the element
elem.remove() //remove the element
jQuery:
$.ajax('https://some.url', {
success: (data) => { /* do stuff with the data */ }
});
Without jQuery with new fetch API is a superior replacement for XMLHttpRequest and is now supported by all modern browsers.
fetch('https://some.url')
.then(response => response.json())
.then(data => {
// do stuff with the data
});