DEV Community

Discussion on: Some libraries you can use with Vanilla JS

Collapse
kigiri profile image
Clément

Vanilla js librairies, how does that makes sense ?

I thought vanilla was js precisely without libs

Collapse
mudlabs profile image
Sam

Vanilla JS is when you don’t abstract away to a framework like React or JQuery etc... You can still use libraries.

Collapse
vladimirc profile image
Vladimir C

This totally makes sense to me in a matter that the "library" doesn't have any other dependencies like jQuery, React/Vue, etc. i.e. if you're familiar with JS you can just get the library and start using it without cognitive overload by finding that you also have to use that on a specific platform only, having other packages installed and be in a parallel universe.

Collapse
bigbott profile image
bigbott

This totally makes sense to any seasoned developer or any backend developer. But frontend developers nowadays have a mess in their heads. They believe that React is a library because they thought to believe this. Therefore they don't understand completely what a library actually is. Hence a comment: "Vanilla js librairies, how does that makes sense ?" with 17 likes. Awful.

Thread Thread
kigiri profile image
Clément

Kindly please describe what is a library to you, their might be an interesting discussion here.

If we take the example of the editor.js "library":

  • it's 574k of js bundled
  • has dependencies (at least highlight.js for syntax highlighting)
  • has an ecosystem of plugins all only working for this library

The line between library and framework is a bit fuzzy, I would still consider react a framework because it is how people use it and arguably the recommanded way to use it.

My message was not about react being a lib, more than using huge library not the spirit of what I would call vanilla JS.

Thread Thread
bigbott profile image
bigbott

It is not fuzzy and it never was. It always was simple and clear. It became fuzzy when promoters of React decided to call it "library".
A library is just a set of methods/functions regardless of its size. It can be GB in size and it still will be the library. Editor.js is a perfect example of a library. Another one jQuery - 30,000 plugins and why it even matters?

Framework on another side can be several lines of code, but still, be a framework just because it requires your code to be written in a certain way. React which requires extending classes and implementing methods is a perfect example of a framework.

General principle:
Your code calls the library, but the framework calls your code.

Speaking of "Vanilla JS", "Vanilla JS" is a part of jQuery hate strategy invented by the same frauds who call React the library.

The power of a language is in its libraries and frameworks. "Vanilla JS" is nonsense, the same way as "Vanilla Java" or "Vanilla Python". We just need to call libraries - libraries and frameworks - frameworks and use them where they make sense.

Thread Thread
james_palermo_bc208e463e4 profile image
James Palermo

Thanks bigbott, I was skimming the comments and thinking “please tell me SOMEONE knows what a library is! Big ol bundle of code!”

Maybe people don’t “need” to learn C++ but I swear a week with it and people wouldn’t be confused by stuff like the idea of a “library” that is just a big block of text.

It’s almost like how a real library is a place that holds lots of useful information data and methods to achieve things. Weird, right? 😜

Collapse
kjellski profile image
Kjell Otto

I don't think that's necessarily the case - I always thought that it means without the prerequisite of a framework like Angular or library like React...

Collapse
casperbraske profile image
Luis

My exact thought.

Collapse
z2lai profile image
z2lai • Edited on

I get that there might be an established definition of Vanilla JS. But isn't Vanilla JS libraries just JS functions packaged together. I don't see much of a difference between keeping the JS all in one file, vs storing it in another module and importing it.

Collapse
kigiri profile image
Clément

For me the difference is, directly using the browser API and writing code just for your needs and understanding the API behind the code.

In a way, react can be use as just a vanilla JS library in that case, you don't even need to write JSX and can use it for some elements only... It's probably lighter than some of the libraries listed in this article.

Collapse
itwasmattgregg profile image
Matt Gregg

With this definition then libraries like Vue and React are "Vanilla JS" libraries.

Thread Thread
z2lai profile image
z2lai

Yeah good point. I think of React as non-vanilla because of how many layers of abstraction it has. But I guess ultimately, if there's even one layer of abstraction, like packaging a one-liner into a library, then it might as well be considered non-vanilla.

Collapse
merthod profile image
Merthod • Edited on

Because you can use them with vanilla JS, w/o dependencies nor supersets.

Collapse
hakimio profile image
Tomas Rimkus

I guess, it means it doesn't require some framework like React, Angular, Vue, JQuery, etc.

Collapse
kayron013 profile image
Angel Campbell

JQuery isn't really a framework though, yet I'd still consider it non vanilla JS.

Collapse
hseritt profile image
Harlin Seritt • Edited on

True but ... this list is f****** awesome! I'll allow it! :-D