That moment you convert jQuery to JavaScript... I feel super charged and awesome! π€ π
My latest conversion:
jQuery
$(elem).addClass('anim-elem');
JavaScript
if (elem.classList)
elem.classList.add('anim-elem');
else
elem.className += ' anim-elem';
What was your last jQuery to JavaScript?
I wouldn't say it makes feel great but for the amount of typing an incredible amount faster
$(".someClass").css('display', 'none')
var elems = document.querySelectorAll(".some-class); var i = elems.length; while(i--){ elems[i].style.display = 'none' }
jQuery is not needed since ES5. For many years I am using mostly Vanilla JS, currently ES6. Since there are no many Vanilla JS libraries you could use out of the box I created https://bunnyjs.com
Vanilla JS is also the most powerful, fastest and simplest tool for the right job.
Marco Alka
Software Engineer, Technical Consultant & Mentor
First of all: Good for you, welcome to a better world :)
Secondly: Looking at the JS you wrote there, it looks very tedious. I agree that VanillaJS is very important. But at the same time, it is just as important to keep proven ways to make your life easier. You should write a wrapper for that construct or use a library which contains that wrapper for you. Preferably one which is lightweight and just wraps over VanillaJS instead of introducing its own objects and methods for every little thing.
As for what I replaced: Nothing, really. If I already use jQuery in a project, I will keep on using it. I am not paid for removing jQuery, just for the heck of it. I will, instead, relinquish it in future projects. But if I had to pick one thing which I wrapped, it would probably be
$.ajax(), since I use it quite often :)