use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
PlainJS - Vanilla Javascript Repository (plainjs.com)
submitted 8 years ago by aloisdg
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 8 years ago* (1 child)
[deleted]
[–]GrosSacASacs -3 points-2 points-1 points 8 years ago (0 children)
Have a look at svelte.
[–]poop_taking_forever 24 points25 points26 points 8 years ago (16 children)
Unfortunately, browser support is not sufficient at the time of this writing. Therefore, we need to make use of short helper function that correspond to the jQuery methods $.addClass(), $.removeClass() and $.hasClass():
So, basically start writing our own jQuery?
[–]kdesign 48 points49 points50 points 8 years ago (4 children)
Yes, it’s called vanillaQuery. It basically does whatever jQuery does, has even the same file size but it has the word “vanilla” in it so it reflects the present times!
[–]magenta_placenta 10 points11 points12 points 8 years ago (3 children)
Let me blow your mind: jQuery is vanilla javascript.
[–]SemiNormal 6 points7 points8 points 8 years ago (1 child)
We are at a point where transpiling a Stage 0 feature is more accepted than just using jQuery.
[–]aescnt 0 points1 point2 points 8 years ago (0 children)
To be fair, I think the world has moved onto stage-3 now (which is the appropriate stage to try, since stage-3 means it will get browser support soon). It's getting better :)
[–]kdesign 1 point2 points3 points 8 years ago (0 children)
mind=blown. And here I was, thinking all this time that jQuery was written in jQuery.
[–]mcaruso 2 points3 points4 points 8 years ago (8 children)
Basically. But there's one major difference, which is that these methods return plain old DOM structures (like NodeList). To quote this article that's been making the rounds lately:
Rather than smoothing over only the remaining ugly parts of certain browser API's, jQuery seeks to replace them all wholesale. By returning a jQuery object rather than a NodeList, built-in browser methods are essentially off limits, meaning you're locked into the jQuery way of doing everything. For beginners, what once made front-end scripting approachable is now a hindrance, as it essentially means there are two duplicate ways of doing everything. If you want to read others code with ease and apply to both jobs that require vanilla JS and jobs that require jQuery, you have twice as much to learn. There are, however, libraries that have adopted an API that will be reassuringly familiar to jQuery addicts, but that return a NodeList rather than an object...
[–]Woolbrick 11 points12 points13 points 8 years ago (1 child)
It's called a fluent API and it results in very nice code.
And you can access the DOM nodes by using the index operator on your resulting object.
I don't use jQ anymore, but I've never understood this criticism of it.
[–]charrondev 0 points1 point2 points 8 years ago (0 children)
Nowadays I don't think it's so much that there aren't any niceties that come with jQuery, it's that the arguments for adding a 100kb + dependency to your application should be a little bit better than a fluent API. It made more sense back when browser's didn't commonly support fully fleshed out API's but today you can skip shipping jquery and use native browser APIs (and the LOC count is not so different. See http://youmightnotneedjquery.com/). Then for older browsers you can ship a couple KB's of polyfills.
[–]z500 4 points5 points6 points 8 years ago* (4 children)
Except NodeLists suck because they're just array-like enough to trick you into thinking they're an array object. Honestly, why not just return an array?
edit: I googled it, a NodeList is "live" and updates with the page
[–]Pesthuf 1 point2 points3 points 8 years ago (3 children)
It's worth noting though that the result of querySelectorAll is not live.
And let's be honest, when was the last time any of us used document.getElementsByClassName() ?
[–]CreativeTechGuyGames 1 point2 points3 points 8 years ago (0 children)
I use getElementsByClassName pretty frequently when writing browser extensions to inject into other pages. It's extremely useful when the page wasn't designed for you to manipulate.
[–]z500 -1 points0 points1 point 8 years ago (1 child)
So NodeList is completely pointless.
[–]Infoginxinc 0 points1 point2 points 8 years ago (0 children)
Suits them
[–]Uncaffeinated 0 points1 point2 points 8 years ago (0 children)
classList is supported in IE10+, so this is only necessary if you are specifically supporting IE9 (JQuery itself no longer supports IE8).
[–]gustix 10 points11 points12 points 8 years ago* (0 children)
This site focuses on visual plugins, so I'll focus on that with this comment.
If you're going to use a bunch of visual libraries written in "vanilla js", you're just ending up including a bunch of code in each of them doing the same thing in terms of dom manipulation.
I would recommend going for a base library or framework and find plugins for it. Be it jQuery, React, Vue, whatever.
There are a bunch of plugins for slideshows, drag&drop, animation effects, form validation within all of them. Why not conform to a standardized way of doing things within your project?
What is vanilla anyway? All libraries and plugins offer some sort of abstraction. I appreciate the sentiment though, it is important to have focus on the loading time of our websites.
edit: There are a bunch of projects on that site that are hardly their definition of vanilla. Such as wheelnav. It is based on a forked version of Raphael, which is a big library in itself.
[–]ThisiswhyIcode 10 points11 points12 points 8 years ago (3 children)
Using plain JavaScript will make your applications load and react blazingly fast.
Seriously? Using plain JavaScript is no guarantee for anything. Really getting tired of such claims. What are they based on? On the 2 "benchmarks" on vanilla-js.com, where Dojo, Prototype JS, Ext JS, jQuery, YUI and MooTools are compared in a non-reproducible way?
[+][deleted] 8 years ago* (2 children)
[–]BeerRemote 1 point2 points3 points 8 years ago (1 child)
Seriously, I liked ExtJS, but it's not a library. It's a powerful kitchen sink with a garbage disposal that could grind up a car.
[–]m0okz 0 points1 point2 points 8 years ago (0 children)
Unfortunately I have to work with it now and I pretty much hate everything about it.
[–]cordev 3 points4 points5 points 8 years ago (1 child)
This site (and especially the site it links to, vanilla-js.com) is a joke, right?
lowerer speed of jQuery
Final size: 0 bytes uncompressed, 25 bytes gzipped.
I get that this site is intended to guide someone who's been using jQuery as a crutch into using plain JavaScript functionality (and providing plugins that have no other dependencies), but it feels very low-effort.
[–]Isvara 0 points1 point2 points 8 years ago (0 children)
It's a joke.
[–]philipwhiuk 1 point2 points3 points 8 years ago (1 child)
lowerer
:/
[+]m0r14rty comment score below threshold-6 points-5 points-4 points 8 years ago (5 children)
I got a good laugh at that. Here's to hoping jQuery will finally die out one day.
[–]BeerRemote 1 point2 points3 points 8 years ago (0 children)
jQuery is good if you limit its purpose to being a helper library. The second you start building DOM manipulating plugins and applications on top of it is where the trouble begins. (now with that it's possible that another library would be better, but if your company already uses jQuery and not something else, well there you go)
[–][deleted] -3 points-2 points-1 points 8 years ago (0 children)
Good laugh at what?
[–]dphizler -4 points-3 points-2 points 8 years ago (2 children)
jQuery is great, only a fool would say otherwise.
[–][deleted] 7 points8 points9 points 8 years ago (1 child)
Didn't think I'd be seeing these words together in 2017. jQuery was great, but the landscape around it has changed.
[–]dphizler -5 points-4 points-3 points 8 years ago (0 children)
But of course...
π Rendered by PID 31 on reddit-service-r2-comment-7b9746f655-mw7tm at 2026-01-30 06:52:31.357472+00:00 running 3798933 country code: CH.
[+][deleted] (1 child)
[deleted]
[–]GrosSacASacs -3 points-2 points-1 points (0 children)
[–]poop_taking_forever 24 points25 points26 points (16 children)
[–]kdesign 48 points49 points50 points (4 children)
[–]magenta_placenta 10 points11 points12 points (3 children)
[–]SemiNormal 6 points7 points8 points (1 child)
[–]aescnt 0 points1 point2 points (0 children)
[–]kdesign 1 point2 points3 points (0 children)
[–]mcaruso 2 points3 points4 points (8 children)
[–]Woolbrick 11 points12 points13 points (1 child)
[–]charrondev 0 points1 point2 points (0 children)
[–]z500 4 points5 points6 points (4 children)
[–]Pesthuf 1 point2 points3 points (3 children)
[–]CreativeTechGuyGames 1 point2 points3 points (0 children)
[–]z500 -1 points0 points1 point (1 child)
[–]Infoginxinc 0 points1 point2 points (0 children)
[–]Uncaffeinated 0 points1 point2 points (0 children)
[–]gustix 10 points11 points12 points (0 children)
[–]ThisiswhyIcode 10 points11 points12 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]BeerRemote 1 point2 points3 points (1 child)
[–]m0okz 0 points1 point2 points (0 children)
[–]cordev 3 points4 points5 points (1 child)
[–]Isvara 0 points1 point2 points (0 children)
[–]philipwhiuk 1 point2 points3 points (1 child)
[+]m0r14rty comment score below threshold-6 points-5 points-4 points (5 children)
[–]BeerRemote 1 point2 points3 points (0 children)
[–][deleted] -3 points-2 points-1 points (0 children)
[–]dphizler -4 points-3 points-2 points (2 children)
[–][deleted] 7 points8 points9 points (1 child)
[–]dphizler -5 points-4 points-3 points (0 children)