Difference Between Vanilla JavaScript and JavaScript (Explained)
What Vanilla is actually all about.

You are probably here because you are more curious about knowing what Vanilla JavaScript and JavaScript have in common.
If you want a straight answer on this topic, I wrote an article with just a single word explaining the difference between them, you can check it out by clicking HERE πββοΈπββοΈπββοΈ
But if you still want to know more, this article is for you, let's get to it πππ
Let's begin by understanding what the word Vanilla is all about?
Vanilla is when something does not have any special or extra features; it is ordinary or standard.
Another Word for Vanilla includes
Plain
Default
Pure
Simple
Undiluted
Explanation
A perfect example for this article is an ICE CREAM

We generally know that Ice Cream also comes in different colors and ** flavors**.

Ice Cream Popular Colors and Flavours includes
Vanilla (default).
Chocolate.
Cookies N' Cream.
Mint Chocolate Chip.
The first Ice Cream image above with a tea-spoon is referred to as Vanilla Ice Cream, Plain ice cream, Simple ice cream, or undiluted ice cream because it does not contain extra ingredients apart from its natural taste and color, this can also be called the original form of ice cream, before other flavors, coloring, and refined sugar are added.
Other types of ice creams are called Non-Vanilla Ice Cream
So, now that we know that, whatever is in its original state is Vanilla and when combined with something else to make it look nicer, it is Non-Vanilla.
How does this relate to JavaScript?
Let's proceed by explaining JavaScript the same way we understood ice cream π€·ββοΈπ€·ββοΈπ€·ββοΈ
What is JavaScript? π€
JavaScript, often abbreviated as JS, is a programming language commonly used to create interactive effects within web browsers.
It was originally developed by Netscape as a means to add dynamic and interactive elements to websites. Like server-side scripting languages, such as PHP and ASP, JavaScript code can be inserted anywhere within the HTML of a webpage.
Likewise, JavaScript has several frameworks and Libraries of its own, which includes
React JS (Leading and Most Popular)
Angular
Vue Js
JQuery etc.
Backbone
Node
Ember
Meteor
When you're writing in any of these frameworks or libraries, it is believed that you're writing in higher or mixed JavaScript and can be classified as Non-Vanilla or Diluted Javascript.
Example: Given a paragraph tag in an HTML file
<p class="blog-title">Vanilla JavaScript</p>
let's see how this is accessed or selected in jQuery(Diluted JavaScript) and Plain JavaScript.
// jQuery, select all instances of .box
$(".blog-title");
// JavaScript syntax to select first instance of .blog-title
document.querySelector(".blog-title");
// JavaScript syntax to select all instance of .blog-title in our HTML file
document.querySelectorAll(".blog-title");
The above code is an example of selecting elements through their class name in both jQuery and JavaScript, but jQuery syntax for selecting an element with their class name is a two in one of the JavaScript syntaxes.
More Example:
Let's see how we can change elements styles in jQuery and JavaScript.
// With jQuery
// Select .blog-title and change text color to #EF3100
$(".box").css("color", "#EF3100");
// With Natural JavaScript
// Select the first .blog-title and change its text color to #EF3100
document.querySelector(".box").style.color = "#EF3100";
Based on the examples given above, it is obvious that jQuery has a shorter syntax than Plain JavaScript and simplifies DOM scripting.
Vanilla JavaScript or just JavaScript refers to ES5/6/7, just raw JavaScript. Non-vanilla JavaScript includes Libraries and frameworks like jQuery, React, Angular, Typescript, etc.
And that a wrap on this topic.
I hope this helps explain the differences! If you want to know more about the 2021 latest Vanilla or Plain JavaScript features follow Catalin Pit and Brayan Arrieta Alfaro they both have a great article on that, be sure to follow my blog and my Twitter account for more coding adventures.
Useful Links
Link to Catalin Pit's Article on Latest JavaScript Feature
Link to Brayan Arrieta Alfaro's Article on Latest JavaScript Feature
About the author
- Software engineer and developer educator with over four years of experience building production-grade digital products for platforms serving millions of developers globally. Software engineer at Hashnode & Bug0
Comments
Join the discussionI feel the title is somewhat misleading. It's all javaScript at the end of the day, there is no magical transformation into some other form. Whilst I found this to be an interesting article, I think it's largely too involved.
Vanilla JavaScript is JavaScript, vanilla is merely a subjective term. In modern development, "vanilla" javascript is a rather obtuse moniker applied to code which is often describing code written with the base javascript feature set. That is no experimental features, no language transpiler into any newer ECMA script versions, or typescript / flow like things, that's it. However, this is not a definitive or authoritative description.
After all jQuery is still vanilla javascript itself, just written extremely strategically. Its use contextually is what raises the vanilla perspective.
Thanks a lot @thebarefootdev
The title isn't what I picked randomly, It is me answering the question I was asked by someone.
After all jQuery is still vanilla javascript itself.
I think the definition of jQuery which is a library (or framework) built with JavaScript does not agree with that
just written extremely strategically
and you also did.
you can provide a useful resource to help understand what you mean.
built with JavaScript
Indeed it is ;)
Well just look at the source code for jQuery selector
import jQuery from "../core.js";
// Note: an element does not contain itself
jQuery.contains = function( a, b ) {
var adown = a.nodeType === 9 ? a.documentElement : a,
bup = b && b.parentNode;
return a === bup || !!( bup && bup.nodeType === 1 && (
// Support: IE 9 - 11+
// IE doesn't have `contains` on SVG.
adown.contains ?
adown.contains( bup ) :
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
) );
};
Thats it, nothing non vanilla about this!
you're still using jQuery not Plain JavaScript to solve this problem at the end, that's not pure JavaScript IMO @thebarefootdev
It's just another named vanilla module, in the same codebase. Scoping is not a non Vanilla practice.
"that's not pure JavaScript"
Then what is module importing?
Perfect example!
thanks Armando Mora Valles, I hope you enjoyed it?
thanks, mama gee
Omooo see illustration, nice write up. Soap never reach miooπ€²
Thanks for the feedback
lolxx...come back to school
thx Ayodele Samuel Adebayo for the reference
you did a good job on the article. well-done




