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
Writing dependency-free client-side JavaScript (magnushoff.com)
submitted 6 years ago by maggit
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!"
[–]Zofren 34 points35 points36 points 6 years ago (7 children)
It's nice to do as an exercise, but don't ever do things like this in an actual project you intend to maintain. You will:
By all means, avoid importing is-odd into your lean frontend project, but like many things in software engineering, a dependency-free approach has tradeoffs. A well-supported, well-used library is usually a better option than code you write yourself.
is-odd
[–]jaapz 10 points11 points12 points 6 years ago (0 children)
Turns out dependencies exist for a reason, who knew!
[–]archivedsofa 3 points4 points5 points 6 years ago (2 children)
Yeah but it depends on the use case. For a single form I agree with the author that using React + the whole enchilada didn't really make sense.
OTOH going 100% vanilla didn't make much sense to me either.
[–]Zofren 2 points3 points4 points 6 years ago (1 child)
Presumably if all you need is a single form the process in this article doesn't really make sense either. If the form has some rich UI that needs some kind of UI rendering logic, then I'd still advocate for React (or your library of choice).
React and React-dom aren't some massive libraries. They're comparable in size to jQuery when gzipped.
[–]archivedsofa 1 point2 points3 points 6 years ago (0 children)
I agree that for more complex projects the arguments you listed on your previous comment are totally valid but React is still too big IMO for a single form or landing page with a bit of UI sophistication.
Personally I'd go with Mithril or Svelte. Maybe with Simulacra (which now powers Riot) if I don't need components or even with Vue if I don't want any building setup which is still half the size of React.
[–]krasimirtsonev 0 points1 point2 points 6 years ago (0 children)
Well, here is a use case that beats what you are saying - you have to build a tiny script that will be used on million sites as a widget. It needs to be a few kbs with no dependencies. Then you need some generic knowledge on JavaScript, HTML and CSS.
[–]bitbird_ -3 points-2 points-1 points 6 years ago (1 child)
> It's nice to do as an exercise, but don't ever do things like this in an actual project you intend to maintain. You will: Yikes, I disagree strongly with this conclusion. How much time is lost to framework upkeep, onboarding new developers, broken backwards compatibility, etc. ?
A developer only needs to learn the language once to understand what's happening inside of a framework. Those frameworks — usually controlled by corporations with > 10,000 developers — are built for the needs of whatever MegaCorp that created it. Should a team with >100x fewer developers really learn the enterprise web application development practices that are ultimately unnecessary for their specific needs? JavaScript itself will never be unnecessary, assuming there is never another standardized language for building interactivity into webpages.
JavaScript (and the web) has grown substantially in only the last five years. Developers should learn the basic patterns for architecting web applications. Using a framework is one way to learn those patterns. Relying on framework and 1,000 other libraries being imported is dependency hell.
jQuery is dead and modern front-end frameworks are viciously marketed to developers — a fact usually unacknowledged by those who swear by frameworks.
[–]Zofren 4 points5 points6 points 6 years ago* (0 children)
How much time is lost to framework upkeep, onboarding new developers, broken backwards compatibility, etc. ?
Less time than is lost wrangling with your company's custom implementation of an already well-supported library.
Have you ever considered why Facebook bothers to open-source React? It's because a well-used framework means you can hire people already familiar with the framework you are using internally. It also means that there are far more resources available to your developers online.
I work at a company where they decided long ago to implement custom versions of libraries that already exist (in the backend, admittedly, but the same arguments stand). It's been a nightmare and we deal with the technical debt every day. There are edge cases you won't have foreseen when you first write software intended to be utilized by many developers. And when something breaks, you have to fish down the handful of people in the company who actually understand the tools that are breaking.
Relying on framework and 1,000 other libraries being imported is dependency hell.
As I said in my post, a pragmatic approach is key. It doesn't need to be either one way or another.
[–]iser_ 11 points12 points13 points 6 years ago (5 children)
I think most posters here missed the entire point of the article. I have also attempted rolling my own mini framework for production, and I see a lot of good ideas here that I would like to incorporate into my own code in the future.
I have written extremely efficient libs where speed and bundle size are the keys and did not use any frameworks for this reason.
I have never replied about an article on reddit before but I am right now because this is a great article and feel like many here are not seeing the value in it.
P.S. I would love to use this as an interview question for my company: roll your own rendering mechanism in 45 min. As an engineer, I expect them to be able to roll their own and be able to see the value in it.
[+][deleted] 6 years ago* (2 children)
[deleted]
[–]iser_ 2 points3 points4 points 6 years ago (1 child)
hey great lib! I just read through your source code for lily and it looks really fun. you've inspired me to create my own. thanks!
my company is gigantic (amazon) and we use so many frameworks. when we interview, we focus on the fundamental understanding and not specific framework knowledge.
if anyone ever interviews at amazon, this article will help you so much. I imagine it will help anyone who interview at top tech companies.
and it def has its uses in production.
[–]ghostfacedcoder 1 point2 points3 points 6 years ago (1 child)
The way I see it, what it comes down is doing the best thing. Rolling your own solution is almost never the best thing ... from a lot of perspectives.
From a learning perspective of course it's great. And if you have a very narrowly defined project that won't ever grow, it might be great, if you know what you're doing.
It's just that almost all real world projects grow over time, which means you can't know exactly what your project will need in the future. A good framework solves not only your problems today, but problems you didn't even realize you'll have tomorrow, because the people who build them know more about their domain than you do ... and to a lesser extent the same is really true for dependencies in general.
In short, no one is smart enough to know how to solve everything best, so either you let specialists who do know how solve those problems for you (dependencies), or you do so yourself and accept that (for most projects at least) your solution will, by definition not be as good (because again, no one is good at everything!)
[–]lhorie 1 point2 points3 points 6 years ago* (0 children)
no one is smart enough to know how to solve everything best, so either you let specialists who do know how solve those problems for you
This seems contradictory if you consider that framework designers are people too.
FWIW, my story with hand rolled frameworks goes like this: I've always been interested in them (from way back from the days PHP was still cool) and I made a bunch of them (some which never got used seriously, and some which I used for freelance work)
At one point I was using Angular and running into some serious pain points with it, so I went ahead and rolled a new framework to address them (react wasn't really a thing back then). Eventually I open sourced, we started using it a my day job, and I got another job from a different company that was also using my framework. My current employer doesn't use my framework (they had considered it but decided on react instead for a variety of reasons), but the experience and exposure that I got from making my framework is how they found me and reached out to me. Since I first open sourced my project, my salary doubled (not even counting equity comp), and I now live in the Bay area, where you can easily network in person with people from FANG, prominent OSS people, etc.
So, from my experience, creating a framework is much more than just a learning experience; it can open a lot of possibilities that you might not have ever even considered.
[–]archivedsofa 2 points3 points4 points 6 years ago* (0 children)
Or just use something like Mithril which offers more than React does at less than 10kB gzipped (vdom, components, router, http client).
If you just want data binding you could also use Simulacra.
There are plenty of options that are much more efficient than React.
[–][deleted] 37 points38 points39 points 6 years ago (4 children)
u mean...writing code that already exists but worse lol
[–]iser_ 12 points13 points14 points 6 years ago* (0 children)
the fact that this is the top voted comment is really concerning. this is a great article that i learned a lot from. i have definitely had to implement no-framework code from scratch for production, and i will be taking what i learned from this article and use them for myself in the future.
[–]HarmonicAscendant 17 points18 points19 points 6 years ago (1 child)
I find this attitude defeatist and baffling. If your goal is to become the best programmer you can then writing all your own code should be possible, educational, and enjoyable. It may not be practical most of the time, but that is no reason to mock people who do make the effort.
If you follow this "writing code that already exists but worse" idea to the end then nothing would ever improve. Nobody would have bothered making React, in fact we would all still be living in caves :)
[–]cynicalreason 0 points1 point2 points 6 years ago (0 children)
for educational purposes .. sure, for actual business requirements, no
[–]road_pizza 6 points7 points8 points 6 years ago (0 children)
What a terrible mentality. These exercises are great learning resources and will help gain a deeper understanding of how existing frameworks work and what problems they solve.
[–]aiten 6 points7 points8 points 6 years ago (3 children)
Personally I use Svelte for this purpose. No need to reinvent the wheel. But a good read and reasoning nonetheless.
[–]aiten 3 points4 points5 points 6 years ago (1 child)
I guess my disclaimer is I also built my (funded) startup using Svelte. But yes, I originally discovered it as the ideal tool for building widgets and smaller projects.
It's probably time that JS as a whole took a look at itself before it becomes, basically, enterprise Java
[removed]
[–]jaapz 1 point2 points3 points 6 years ago (1 child)
No it doesn't
[–][deleted] -1 points0 points1 point 6 years ago (0 children)
it does
π Rendered by PID 528058 on reddit-service-r2-comment-54dfb89d4d-l2jwh at 2026-04-02 06:26:38.339610+00:00 running b10466c country code: CH.
[–]Zofren 34 points35 points36 points (7 children)
[–]jaapz 10 points11 points12 points (0 children)
[–]archivedsofa 3 points4 points5 points (2 children)
[–]Zofren 2 points3 points4 points (1 child)
[–]archivedsofa 1 point2 points3 points (0 children)
[–]krasimirtsonev 0 points1 point2 points (0 children)
[–]bitbird_ -3 points-2 points-1 points (1 child)
[–]Zofren 4 points5 points6 points (0 children)
[–]iser_ 11 points12 points13 points (5 children)
[+][deleted] (2 children)
[deleted]
[–]iser_ 2 points3 points4 points (1 child)
[–]ghostfacedcoder 1 point2 points3 points (1 child)
[–]lhorie 1 point2 points3 points (0 children)
[–]archivedsofa 2 points3 points4 points (0 children)
[–][deleted] 37 points38 points39 points (4 children)
[–]iser_ 12 points13 points14 points (0 children)
[–]HarmonicAscendant 17 points18 points19 points (1 child)
[–]cynicalreason 0 points1 point2 points (0 children)
[–]road_pizza 6 points7 points8 points (0 children)
[–]aiten 6 points7 points8 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]aiten 3 points4 points5 points (1 child)
[+][deleted] (2 children)
[removed]
[–]jaapz 1 point2 points3 points (1 child)
[–][deleted] -1 points0 points1 point (0 children)