Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is plain vanilla JavaScript better than using frameworks like jQuery or MooTools? [closed]

I am wondering if it is a good idea to rely on frameworks like jQuery or MooTools or should we just use plain JavaScript?

Apart from avoiding the re-invention of wheel, do they add any specific value?

Since the frameworks are open to the public, can there be possibility of exploitation of any security holes that might appear (of course, unintentionally :) ) in the frameworks?

Are there any other points that are to be considered when choosing a framework or otherwise?

like image 219
Amit Dugar Avatar asked Aug 03 '10 05:08

Amit Dugar


People also ask

Is vanilla JavaScript good?

Absolutely. The purpose of this post is to emphasize the importance of JavaScript fundamentals for every front-end developer.

Is vanilla JavaScript faster?

You would be surprised but Vanilla js is extremely faster than other JavaScript frameworks. So you can say that it provides better performance than leading front-end frameworks.

What is the difference between JavaScript and vanilla JavaScript?

There's no difference at all, VanillaJS is just a way to refer to native (non-extended and standards-based) JavaScript. Generally speaking it's a term of contrast when using libraries and frameworks like jQuery and React.


1 Answers

  1. Frameworks solve cross-browser bugs which normally would cost hours of your time, so you can focus on functionality instead of worrying about some edge case browser bug.. instead of wasting 4-5 hours solving a bug spend that time with your family.

  2. Frameworks such as jQuery are pretty loaded with stuff like animation, selectors, html manipulation so there's usually some sort of functionality already built into the library, again saving you more time and the API makes it really easy to actually accomplish complex things.

  3. Interpreters and browsers are only getting faster and faster so I don't particularly think it's a huge issue loading an entire library up. In addition thanks to Google et al we get very fast cdns and nowadays lots of sites are using the same exact URI to pull the script in, meaning there's a higher rate of the script getting cached and reused on another site.

  4. Instead of every single web developer having their own library it's much more efficient having thousands of people concentrated to bettering a handful of libraries so cross-browser bugs get documented and fixed.

  5. Competition is a good thing, the result of the slickspeed tests resulted in much faster selector engines such as Sizzle. Developers not having to worry about trivial DOM bugs means more complex libraries are created daily, which means entry-level developers have access to very powerful plugins.

As far as security, jQuery for example will detect if the browser is capable of parsing JSON natively and if so, rely on that. Usually any modern browser will have this, and it's much safer than eval... so jQuery strives to use the safer and more secure methods first. It will only use eval if there isnt a JSON.parse method available.

An important thing to remember in jQuery though is remembering you're still coding in Javascript. Usually people get too caught up in the sugar coated methods and wrapping everything in $, I think it's important to know you can still do this.href instead of $(this).attr('href') if you would like an absolutely normalized uri for example.

like image 87
meder omuraliev Avatar answered Sep 28 '22 00:09

meder omuraliev