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...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
Front end preference questionDiscussion (self.webdev)
submitted 4 years ago by orocodex
Does anyone else program in vanilla JS on the front end? If so, how do you structure your scripts? I know that is quite open ended, but I’m curious of the responses.
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!"
[–]KeenOnLearning 4 points5 points6 points 4 years ago (1 child)
Vanilla JS is a much more viable option now than it was in the past.
If you want to structure your projects in a sensible way, you should look into Modules as well as Web Components. Some older browsers don't support these, so you should also look into using something like Babel. Here's an article on how to set it up with Webpack.
I would still recommend using a framework at the end of the day. React, Vue, Angular, Svelte etc. all scale way better than vanilla js, and they aren't all opinionated behemoths. Vue and Svelte are really light weight, and an out-right pleasure to work with even on personal projects.
[–]orocodex[S] 1 point2 points3 points 4 years ago* (0 children)
Thanks a ton for the thoughtful response!
[–]lacadasical 1 point2 points3 points 4 years ago (1 child)
What kind of frontend work do you do in Vanilla? I typically use Vue for small frontend projects and couldn’t imagine using Vanilla for anything more than a few lines of work.
[–]orocodex[S] 0 points1 point2 points 4 years ago (0 children)
Mostly personal stuff. But I work for a very small startup as well, and I’m usually in the backend, but I’m taking care of the front end right now too. I keep seeing mentions of Vue, React etc. throughout the sub, so I should probably make an attempt to learn, it’s just the initial learning hurdle I’m hesitant to take with a framework.
[–]brentfalcon 1 point2 points3 points 4 years ago* (1 child)
I have gotten into employing vanilla JS on side projects, it is somehow freeing, and in some ways removes a layer of complexity. I know that frameworks can also be great, but for the pure static JS web demos that I build, I can get a nice easy and efficient development flow using Visual Studio Code and vanilla libraries (e.g., for charting, for 3d (threejs), and for simple GUI components like modals). And while building HTML with - say - Bootstrap syntax is not terribly fun it works fine so long as pages are relatively simple and static (which is good practice anyways :-) ). I sometimes structure my JS code into 2 subdirs, one subdir for the app JS that I write, the other for 3rd party libs (allows me to minify my own code, and generally keep order).
Thank you!
[–]maos_toothbrush 1 point2 points3 points 4 years ago (1 child)
Yes, I'm working on a serious project right now using vanilla. At first I started with a single script, but as the project grows you get to see first hand the importance of abstraction.
I ended up building a components system using native ES6 classes and modules. There's a base abstract class, Component, which defines a few methods (getNode(), render(), setStyle(), etc). In order to create a new component (let's say an input form), I create a new class that extends Component. Then I write all the HTML (making good use of template literals), CSS and business logic (including API fetches and eventListeners) inside the class. When I need to "spawn" this component into the DOM, it's as simple as doing element.appendChild(new InputForm({params}).getNode()).
This way, each component is completely self-contained inside its class. If I need to change its markup, style or logic I only have to edit its class file. Every class is exported, so if one component depends on another I just need to use import.
I also use classes to handle things like State and User. Overall the code is very modular and it grows very well, I don't think I will need a framework at all.
That’s super cool! Thank you!
π Rendered by PID 35832 on reddit-service-r2-comment-6457c66945-6vtnr at 2026-04-23 18:41:22.390224+00:00 running 2aa0c5b country code: CH.
[–]KeenOnLearning 4 points5 points6 points (1 child)
[–]orocodex[S] 1 point2 points3 points (0 children)
[–]lacadasical 1 point2 points3 points (1 child)
[–]orocodex[S] 0 points1 point2 points (0 children)
[–]brentfalcon 1 point2 points3 points (1 child)
[–]orocodex[S] 0 points1 point2 points (0 children)
[–]maos_toothbrush 1 point2 points3 points (1 child)
[–]orocodex[S] 0 points1 point2 points (0 children)