888 Views
2 minutes read
Categories
jQuery

Is jQuery still needed?

In the recent months I’ve seen a lot of backlash against jQuery. It is true that when jQuery made it mainstream everyone and their brothers included it on their pages even if it wasn’t needed. Lots of great WordPress plugins also overuse and abuse jQuery on our sites (Netwoven.com included). But even after all this jQuery is an indispensable library in our chest of tools.

The time it would take to write an advanced function like toggleClass is measurable (below is the eleven line JavaScript equivalent). Developers would much rather spend time solving more complex problems than figuring out the JavaScript required to toggle a CSS class. There is also a higher level of knowledge required to be coding in pure JavaScript, jQuery lowers that bar which lets more developers to collaborate on projects.

Javascript translation of toggleClass:

if (elem.classList) {
elem.classList.toggle(className);
} else {
var classes = elem.className.split(' ');
var existingIndex = classes.indexOf(className);

if (existingIndex >= 0) classes.splice(existingIndex, 1); else classes.push(className); elem.className = classes.join(‘ ‘); }

Matthew Maher

About Matthew Maher

Matt Maher is a technical architect with Netwoven who has been working with Fortune 500 companies implementing large scale enterprise systems for the last 10 years.

Matt is an early member of the Netwoven team and has helped grow Netwoven from it’s infancy to the current stages. Matt is passionate about User Interface, SharePoint, Social, and Digital Marketing. His leadership and expertise have helped companies build intuitive, highly effective websites and applications.

Matt holds a BS in Computer and Informational Sciences from the University of Massachusetts.

LinkedinTwitterFacebook

Leave a Reply

Your email address will not be published. Required fields are marked *