[AskJS] Are there people using vanilla JS? If so: What are you doing with it?

AskJS

Everything seems to be about APIs, frameworks, libraries and installable serverside modules nd compiling static sites before deploying them to the web.

But are there still people using vanilla JS? The oldschool stuff that simply runs in the browser by adding <script src="....."> to the HTML's head area without having to set up a "full stack node react latest-buzzword development environment"?

So, all vanilla JS users: What are you using JS for?

For a private project I wrote a custom client-side router and some asynchronous fetching and displaying functions with some logic to format stuff as needed. Total files amount including the index.html: 3. All fully flexible and customizable as needed for the specific project, zero overhead.

Posted Apr 6, 2023, 9:51 AM UTC

2373

I work with vanilla Js.

My environment is sealed. And any library has to go through an intensive inspection to be approved for use. 4 weeks to be able to link bootstrap cdn. Imagine a JS library.

I asked to use date.js and never got an answer.

43

Are there plans to migrate to TS at any point?

4

Ahahah that's the first thing I said when starting.

No. A language change would require...well. A revision of the whole language by security. And then, we would rewrite the entire system and get them approved part by part, which would be time consuming and worth a fuckton of money.

They prefer to have a big, very difficult to maintain shit.

18
bjerh•

That seems... Idiotic.

11

It is. Big corp. Finance.

All the shit moves sooooo slow is infuriating.

But I guess you can't gut a system distributed across 3 continents with thousands of users, 24/7.

It's their rules, so I have to play the game. Quite interesting. I'm there because they are doing fucking crazy things with GCP and AI and I want to get into that.

Right now I just have to hold the project as lead dev for some months more, and then I will go to that team. Less money but bleeding edge shit. You can't have everything. And management in a big corp is a mess, to be honest.

16
Tokikko•

I meant it really is not. If you are working on critical systems stability and security are the number one priority.

5
SaidWrong•

Oh god are you operating without a date library?!?!?

2

Nah fam, don't worry. GPT 4 is allowing me to simply gut date.js design and adapt it to my needs, cutting a lot of stuff I won't use ever.

That way, i preserve my hair, they can review the "library" at faster pace and we all are happy.

-1
FredTrellis•

Drag/drop

UI interactivity

Ajax

18
Snapstromegon•

Even though today I mostly use a combination of these tools:

  • 11ty
  • rollup
  • typescript
  • lit

I've absolutely built many things just using vanilla js in the past and I'm currently contributing to projects that are build only using vanilla js like 11ty.

To my sense using things like bundlers (rollup in my case) that don't really do anything magical aside from actually bundling aren't really against a "vanilla js" style of writing code.

Things I've build in the past using no libs at all include

  • An offline SPA PWA build with web components for a sport event
  • Demos for university projects
  • monitoring dashboards
  • home automation control board
  • CI/CD automation / reporting scripts used in the automotive sector
8
VFequalsVeryFcked•

I still use vanilla JS. I don't use it for much though. Just what I need, as and when I need it. For example, post requests, accordions, button clicks, show/hide elements.

I rarely need JS to do very much. I used to use jQuery, but since JS started catching up with jQuery, it's now better, in my opinion, to use vanillaJS over jQuery. I think this because the jQuery library is huge and not worth importing that library to do the little that you'll do with it.

I mainly used jQuery for ajax requests, but since the advent of fetch, it's now just as easy to use vanilla JS.

7
[deleted]•

[deleted]

1

I'm not a pro developer, but I only use vanilla JS, plus PHP and SQL for backend stuff. Every time I start to learn TypeScript or React or Docker or what have you, it just seems so bloated and confusing. Not knocking them, I recognize that people do amazing stuff with them, I've just never been able to wrap my head around them, and I know JS so well I just don't bump into limitations with it.

Here's one of my primary projects; here's a fun one I mess with every holiday season, and here's something I threw together for my students. The one I've been working on lately, which I'm even more proud of, isn't ready for public consumption yet; feel free to DM me if anyone's curious.

7
jamblethumb•

I'm not a pro developer, but I only use vanilla JS, plus PHP and SQL for backend stuff.

These days, many "pro developers" brag about their inability to do anything useful with vanilla as if that's supposed to be impressive or something.

7
CaptainIncredible•

If a "pro developer" brags about their inability to do anything useful with vanilla JS, I laugh at them. Not usually to their face, unless its warranted.

I had a DB admin tell me once that he didn't even know what SQL was and he never uses it. wtf.

3
jamblethumb•

I laugh at them

It makes me cry. I look at job ads and I know it's because of such people.

2

At my last job, any time I even tried to touch CSS for something UI-related, one guy was like WHOA WHOA WHOA like I was juggling plutonium or something because I dared raise the bar above plugging framework state into the disappearing/reappearing of things.

It's disgusting. TS doesn't help you write better JavaScript. It protects you from having to learn how to write proper JS without making a mess which will in turn teach you many things about not making a mess in strictly typed paradigms as well. But for UI, strict types are a stupid choice. Brendan Eich chose dynamic for a reason. It's less verbose and creates less boilerplate you constantly have to go back and edit when making tweaks to functionality that can get complicated fast. The pace of UI development in most React/TS environments I've seen is glacial and risk-averse to the point of cowardice compared to how far and fast we used to be able to move.

2
jamblethumb•

The pace of UI development in most React/TS environments I've seen is glacial and risk-averse to the point of cowardice compared to how far and fast we used to be able to move.

This sums it up, pretty much.

I also notice more and more developer who claim to have worked on a "large application" but you look at how they write code, and you wonder if the "large" part is just the bloat from all the "best practices" and "design patterns" they apply in all the wrong places and all the wrong ways just to protect themselves from disasters that never happen or look good in front of their peers.

And the worst part is, because they can't imagine writing code any other way, they think you only work on small apps if you show them how they can get shit done with less code. Like that "simple" solution is only for small apps, and with large apps you're supposed to dependency-inject a service for toggling a single boolean flag that shows or hides an element...

1
Jeth84•

Wow, I had way too much fun with the synth one. Love it!

2
kstacey•

I mostly use vanilla JS with JQuery because I don't want to rely on frameworks especially when there is a new one every month that does that same thing as all the other but with a different syntax.

7
Sumofabith•

The big three are still react vue angular. Its been like that for years despite what new js frameworks come out.

4
frosty-the-snooman•

I rewrite expensive frameworks to be safer and easier to use and run, reporting algos, and logical quality control. Many teams are unaware of their archicture stacks, their dependencies, and vectors of attack... I simply script ways to double-check and align business logic across apps from different teams such that "going rogue" and "oops, that shouldn't have went" are no longer in our vocabulary.

Node and npm make my job so much easier.

4
samanime•

I use vanilla JS as much as humanly possible, only pulling in stuff when it is really beneficial.

I use the Lit framework for rendering to simplify rendering and creating web components, but that's about it.

I write my own library for simplifying HTTP calls (wrapping fetch), my own router/SPA nav, etc. Most of those things top out at 100 lines of code, and having full control over it and no added dependencies is well worth the extra work.

For me, a library needs to be either really complex or really large (by necessity) to be worth considering.

4
JohnMunsch•

Vanilla JS is kind of a spectrum. I would typically say that I am "vanilla" because I'm not using TypeScript for my personal projects but I'm still using esbuild to pull in packages from NPM because I cannot easily make use of them otherwise.

So, for example, here's my "dev" command in package.json that I run during development: `nodemon index.mjs & esbuild public/js/main.js --bundle --outfile=public/js/bundle.js --sourcemap --watch`

That's running a Node server in the first part and "building" my JS by pointing to the main.js which pulls in other modules (which may themselves pull in other modules). That's my entire build and the JS files themselves only use standard JavaScript stuff with the exception that I can do something like `import { LitElement, css, html } from 'lit';`.

Given the above, the "build" command is basically the same thing and I use it to create a deployable version of the app: `esbuild --bundle public/js/main.js --minify --sourcemap --outfile=public/js/bundle.js`

So, that's not super vanilla, vanilla. But it's pretty bare bones.

If you'd like to see a simple example of something built this way there's: https://madgameslab.com/ps

Some of the many things I love about that are that there are many Web Components there, a Redux model, interaction with localStorage, etc. yet it gets absolutely fantastic Lighthouse scores (almost 100's across the board) and the built JS is quite small.

3
[deleted]•

[deleted]

3

There are 2 type of developers. One that enjoys building in vanilla. Even if it means to reinvent the wheel. The second is that just wants to get things done. Follow the crowd as they say. Both are fine and we need both. Ones that invent new stuff and others that use them.

3
[deleted]•

Even if it means to reinvent the wheel.

I hear that a lot. But why should I pull half a dozen of dependencies to use a library or framework I use 2-3 components of – instead of just writing my own code just having the things I actually need?

Ones that invent new stuff

Why NOT reinvent the wheel if I have a very specific road to drive on? – Without coming up with new inventions at all …

1
Rguttersohn•

If I don’t need reactivity, I’m using vanilla JS. Or I’m using vanilla JS with a library. For example I’ll use intersection observer to animate a data visual when it’s on screen.

Sometimes I’ll write a custom library for a particular site feature. I usually write it in vanilla JS.

I also don’t use axios just the fetch api.

2
Kosemani2•

For form templates.

2
NYPizzaNoChar•

I wrote a chat system, js on the client side, Python on the server side. No frameworks. Python side uses only the most basic, vanilla imports. os, system, cgi. DB is sqlite, also part of Python.

2
react_dev•

If your website is serverside rendered via some other framework, you’re probably still writing vanilla to hydrate the DOM

2
jamblethumb•

From the hydration standpoint, there's literally no difference between having large parts of the UI pre-rendered as HTML in a static file and doing it with SSR. You can use the same technique with a static index.html and use vanilla to hydrate the DOM.

1
jhoyrtop•

I make my website with it

I like it because when I write the server I really get a good understanding for it and how it all works

if I just throw a plug in at it, it becomes a black box where the only solution is to always throw a plug in at it and that is not as empowering

2
jamblethumb•

So, all vanilla JS users: What are you using JS for?

I use it for web apps. At my previous job, one of the teammates saw some examples I wrote, and wanted to switch. We switched all projects to vanilla within a few months. Worked out very nicely.

2
lhorie•

Outside of work: recently wrote a duolingo-like app for my kids using Node.js. Only one dependency (for db), MPA routing, ML implemented in SQL, KISS on client side stuff (voice synthesis, audio, etc).

At work: I work with framework development, tooling (e.g. CLIs) and CI for a huge monorepo (e.g. dynamic pipeline orchestration), so most of my JS code is vanilla

2
PinksFunnyFarm•

Because im learning and I have no idea how to start using any other framework or library or anything, super lost

2
smrxxx•

Drawing to the canvas. Drawing my house floor plan.

2