315 points · by silent_cal · 4y ago · 397 comments
However, after working for software companies for a few years, it seems like almost nobody uses these technologies in the way they're presented on websites like w3schools to make web applications. Instead, they use component-based frameworks like React. To me, these frameworks seem way more complicated than HTML/CSS/JS, and I don't understand what problem they're trying to solve. What makes the trade-off of all that extra complexity and abstraction worth it? Aren't HTML/CSS/JS perfectly fine and time-tested tools for web development on their own?
That's it - that's the problem they solve. People started writing vanilla HTML/CSS/JS and struggling to make "reactivity" (hence React) work well when web applications got complex with a lot of state to manage. So we started building frameworks on frameworks and abstractions on abstractions and ended up where we are today.
It's gone a bit far but the overall purpose is a valid one.
(From someone who has used React professionally but uses vanilla HTML/CSS/JS for his personal website)
This isn't wrong, but going one level down, this is how it bites you:
- The imperative DOM api just suuuucks. Please try it for yourself to see. Even if you're writing a very limited bit of reactivity in your app, you will be forced to invent your own declarative framework very soon.
- Very hard to make reusable components (at least before webcomponents, which I haven't used personally)
If you want to stay close to vanilla, I recommend one of the following solutions:
1) https://htmx.org/ 2) https://github.com/hyperhype/hyperscript 3) https://github.com/vuejs/petite-vue
This looks like pug/slim and other templating to remove xml from pages but instead of just something like
body
p
|
This is a test of the text block.
you get something like: var h = require('hyperscript')
h('p', "This is a test of the text block")
and I want to know why would you want the entire page in JS objects?personally I like the way htmx, vue, alpinejs do things with basically embedding actions/events on the existing xml structures. It's more an abstraction over existing html, than totally redoing or replacing html. That seems like a case of 'we knew we could do it, but never stopped to ask ourselves if we should' ...
Turbolinks + stimulusjs is also another great stack for mini-frontend frameworks. Also super fast.. turbolinks can go well w/ anything though including htmx or alpinejs, but there's a lot of tutorials on stimulus+turbolinks.
The fact that this works, didn't take long to write (though I'm very much still learning this stuff) and is very fast leads me to question your statement that "The imperative DOM api just sucks".
For a small demo like this vanilla JS might make sense but scaling this up does not work (once your rendered HTML reaches a certain size it's jarring when it re-renders, same deal if you have interactive UI that you are rendering out) and if you need to make 10x of these demo sites you are copy/pasting a bunch of code versus leveraging a framework that handles that stuff for you. Yes, frameworks raise your "floor" of code-size but they provide an excellent foundation to build on and skills you can reuse across projects instead of them all being one-off or having to copy/paste a bunch of code.
I don't think you can judge if the DOM api sucks if you are using a "simple demo app" as your baseline, though.
They are of course the valid opinions of a neophyte but don't expect anyone to take you seriously.
Look how slow the text renders when you hit reload.
The content of the <code id="code-container"></code> is not going to change. Just put it inline:
<code id="code-container">
<li>async function n2sort( data, view ) {</li>
<li> const n = data.length;</li>
<li> for( let i = 0; i < n; ++i ) {</li>
<li> for( let j = 0; j < n; ++j ) {</li>
<li> if( data[i] < data[j] ) {</li>
<li> swap( data, i, j );</li>
<li> }</li><li> }</li>
<li> await view.addRow( data, `Step ${i + 1}` );</li>
<li> }</li>
<li>}</li>
</code>
(As a joke you could put the actual <script> tag there and style it like script{white-space:pre;display:block} )The external <link rel="stylesheet" type="text/css" href="style.css"> can also be pasted inline between <style></style> tags.
Same for the script at the end of the page, just put the content between <script></script> tags.
All the way at the top a document type would be useful <!DOCTYPE html>
If you want the steps could be replaced by rendering the entire table and hide each line with css. Pressing step only has to reveal the next line.
I personally consider it a good habit to have the buttons update the location.search part of the url then listen for url changes with window.addEventListener('locationchange', function) and modify the page accordingly. It's not particularly useful for this app but its nice to have an url that represents the state of the application.
Is it trying to provide compatibility with quick templates etc or aim to reach jinja level features parity ?
https://github.com/frameable/el
It's just ~150 lines / 2kb, and leverages existing browser functionality to accomplish most of the hard parts. Has observability, reactive templates, scoped CSS, no need for a build process, etc.
I just feel afraid to run into a problem that has already been solved in a big framework and get stuck.
"The unobtrusive JavaScript framework for server-side web applications Unpoly enables fast and flexible frontends for server-rendered HTML views. It has no dependencies and plays nice with existing code."
This is absolutely true, however there are some newer tools that are appearing that make this much easer with vanilla html - htmx, hyperscript, alpine.js for example (links below).
These newer tools are all made possible due to the “new”(ish) MutationObserver api, it allows you to intercept new dom elements being placed into the document. These libraries let you simple decorate your “real” html with extra attributes enabling easer client side state management. No build step required.
My hope is that a combination of these type of tools, js modules and web components will result in dropping all js build tools. With http2/3 we don’t really need bundling. In many ways it the bundling and transpiling process that has contributed the most to the friction with JS development.
My other observation would be that as js frameworks have evolved they have become more “enterprise” ready, adding tooling (complex central state management, strict typing) to make working in large teams on very large codebases easer. Much of this isn’t really necessary for the majority of we development.
- hyperscript@2.0.2 [3.7 kB]
- htmx.org@1.8.0 [36.5 kB]
- alpinejs@3.10.3 [38.1 kB]
- react-dom@18.2.0 [130.5 kB]
Right now my whole (everything js) really complex application is 150 kB minified. Imagine adding React .. urghh unreasonable.
- TypeScript needs transpilation and it’s very popular
- Bundling is still beneficial with H2/H3, if only so that compression can work well
I believe with Dreamweaver MX you could have sort of a template and generate the static pages.
I think this solution wasn't massively adopted because you had to rely on Macromedia server side ( Cold Fusion ).
That was when PHP and ASP entered the scene allowing you to have dynamic pages in a linux or windows server.
At that time, javascript implementations and rendering engines had massive discrepancies, Internet Explorer, Mozilla .., and to solve that emerge the first (that I recall) massively adopted javascript libraries, jQuery & Motools.
Then Ajax[1] became popular because it made posible to interact with the server without refreshing the page, and that's when managing state became a problem in the browser as SPA started to become more and more complex.
It's amusing seeing how we went full circle when SPAs have gotten so heavy and slow that now static page generation it's sold as a killer feature in Nextjs.
When we could do this in 99's version of Dreamweaver with a nice UI. Maybe it's not a fair comparison, but you get my point, >20 years and see where we are.
So sad that Adobe killed them off. I would still be using Fireworks today if I could.
When did "data binding" become "reactivity" (why the need to create a whole new lexicon for the same ol' thing)? A lot of this confusion (as per the OP) could have simply been explained away by saying we needed frameworks to bind HTML (visual components) to data. Two-way binding existed in many desktop frameworks before SPAs were even thought of.
What a refreshing perspective. My personal site is also vanilla HTML/CSS/JS on a self hosted server. I constantly catch flak from all of my software engineering friends for it too, and I'm a little burned out on it.
Edit: I'm a bit burned out on the flak and defending my position; not burned out on the approach :-)
Don't worry, just enjoy the simplicity, the zen and the lightness of this.
(from a professional web developer, if it even matters - but the web, especially JS, was not targeted at professional web developers, which is the reason why JS is so "forgiving" - or was intended as such, but that failed miserably if you ask me)
The frameworks are only really worth their weight if you have a web app. I'd only consider a web framework if there's going to be >2x as much JS as markup.
If you can solve it in 20 lines of CSS / JS then do it.
There are also software engineering (not programming) reasons, mostly because they set standards for stuff like state management, for why they're useful - helps with future maintenance, documentation etc. when you don't have to interpret a custom self-made framework and teach it to hires.
Those engineers sound like the kind I don't like to work with. Giving you gaff for wanting to tinker on your own time is downright haughty.
Framework, no framework, whatever works. I’m a fan of your approach. But it’s interesting to see how abstractions like react have created a class of web developers that may not know their HTML / DOM fundamentals.
I completely understand his approach, was someone breaking into web dev and people demand frameworks and not vanilla, but definitely felt weird to me.
I think that's it. I wonder how far we could go with vanilla js + a dead simple central store implementation that would help update the UI at different places when a value changes.
You might end up re-inventing Svelte by attempting this though.
Though I should note that if this code has a "store.js" file, this is not the kind of store that I had in mind. More like the Svelte store [1], or Redux (which I find awfully complex).
I didn't know the "storage" event on Window [2] (which, for the record, triggers when localStorage is modified from another page. Does not trigger when modified from the same page, which makes localStorage not sufficient as-is to build the kind of store I'm referring to).
[1] https://svelte.dev/tutorial/writable-stores
[2] https://developer.mozilla.org/en-US/docs/Web/API/Window/stor...
https://github.com/numtel/democratic-capital/blob/master/src...
An example template:
https://github.com/numtel/democratic-capital/blob/master/src...
And then in the next breath make some joke about the proliferation of so many different js frameworks.
1000 hours later and 200k lines of code... I just built the next React/Vue/Svelte, now there's even more options to choose from, with same amount of bloat,just different because 'my way' is better than 'their way' - maybe.
https://egghead.io/courses/fundamentals-of-redux-course-from...
I don't think that's the hard part, component reusability and templating is what makes me use a UI framework (also the extra goodies that come with it like accessability, sensible design frameworks, etc.).
As I see it, frameworks are really about making code accessible, while owning as little as possible of it, by this favouring sharing and the interchangeability of work force. Also, they establish a code policy and the kind of general approach, which is again favourable with regard to human resources. (Now you can have multiple phases of development, where neither team knows anything of the other, which would be hardly possible, if you had to own and maintain the stack. In the old paradigm of art versus engineering, it's a massive shift towards the latter. Which certainly is in line with the general trend.)
(Which is something many frameworks try to fix, ignoring that it's already in the core language. Admittedly, IE didn't support this before IE6, but by now this is really cargo cult. If there is `addEventListener`, there's also `handleEvent` and no need for extra bindings.)
Client side frameworks are still missing it, however, when it comes to: 1. Supporting persistent client side state 2. Syncing local state to the server and back 3. Variation of (2) but collaborative state
Aside -- Reactivity could be straightforward in vanilla js with some tweaks to event handling and in-browser support for dom diffing. I made this reactive vanilla js todomvc in ~200 sloc to explore the idea: https://tantaman.com/2021-02-12-Todo-MVC.html
see: https://jsfiddle.net/patrickcurl/zoastuLr/11/
html: 104 lines css: 39 lines js: 62 lines.
The major difference is I can easily 'read' and understand and 'grok' what my code is doing, yours needs more brain power to tie everything together. The majority is layout, css, etc.
Sure vue/react are overkill but alpinejs, etc makes closer to vanilla options viable that still at least have some eye-candy/syntactical-sugar that makes coding sweeter. But, I hate ugly code - I'll abstract away ugly code just to have code that's self-documenting and easy to understand.
You put it in quotes but some might be missing the point you're making which is that React is not reactive.
See this quote from the docs:
> There is an internal joke in the team that React should have been called “Schedule” because React does not want to be fully “reactive”.
Frameworks like Mithril or Imba are not reactive, at all, and they work just fine for many use cases. The advantage is that state can be just vanilla JS. No need for any abstraction.
For example Mithril re-renders everything to the VDOM after a user event (click, etc) automatically. You can also tell Mithril to redraw [0] eg if you have a WS handler or something state change not related to user input.
I think Imba works very similarly but I don't have much experience with it.
It's a super simple mental model which I like a lot more than anything else. I'm mainly using Svelte now though for other reasons.
says who??? UIKit used properly is beyond complete. React just introduces more problems. it's funny because it was invented because people just dont understand how to write code. UI is literally the same as model code. it's all views.
That's a very interesting comment, but it is rather abstract. I think it would be very helpful if you (or someone else) could provide a simple example that illustrates the problem.
This happens often with pages meant to be an app, rather than a page. When they grow beyond a certain size or complexity, it becomes a given.
The strength of the frameworks (React, View, Angular), is to provide a way to create well-scoped (local/small) components that take care of the Model (the data), the View (generally what is called a template), and have a built-in reactive capability that facilites the sync of the Model and the View. That reactivity is extremely powerful because it "watches" all changes of the Model and knows when a change is impactful for the View. It then refreshes the view automatically so that the user instantly sees the impact of its action or any state change in the application.
When you don't have reactivity, it is of course possible to build a UI, however, you will have to rigorously and explicitly update the view yourself. You can use an observer pattern to do so (btw, under the hood, reactivity is provided by an implicit and automated observer pattern, so that all data of the model become "observable"). In any case, when you don't have reactivity, it gets more complicated and you have to really know what you are doing because your UI code can become a big mess really easily.
You asked for an example. Imagine you have a UI with the check box and when the user checks it, it shows an input so that the user can enter some text to precise some data. In general, you can implement that behavior really easily with a reactive framework. Here is the pseudo code (not meant to be compiled).
The view: <input type="check" model="checkvalue" /><IF condition="checkvalue"><input type="text" model="textvalue" /></IF>
The model: { checkvalue: false, textvalue: undefined}
The important here is the IF tag, which depends on the checkvalue of the model. When this value is false, the text input does not show and vice-versa. It is fully automatic thanks to reactivity. If you don't have reactivity, you need to refresh the view manually when checkvalue changes, and you can imagine it can become quite messy when the view and the model get bigger :)
All that being said, reactivity, if employed poorly, can also become a mess and tigger a lot of unnecessary updates of the views. That's probably why some people complain about framework performances. Of course the role of the framework is also to give you a "frame of work"... if you go out of the frame, that's usually quite bad...
And finally, you can completely develop a small UI with no reactivity applying a MVC pattern with explicit update. That would just make the code more verbose, but IMO, it is doable if you know what you are doing. And it can probably be more efficient in some cases because you don't rely on the framework magic (you can decide in your program when to update the view).
Perfectly reasonable isn't it?
There's a reason developers are constantly inventing ways to remove state from their code. Managing state is messy. Frameworks simply move it around.
Most react apps would be better off written in PHP, html, and progressively enhanced JS.
This is coming from a react developer. Most of what I do is bullshit work someone else invented for me.
But it pays well so ohwell.
Back then it was called DHTML or Dynamic HTML and then evolved into the HTML5 standard later on. The syntax of React & Vue is just too weird for me. Frankly I've reached a framework fatigue after learning jQuery inside out which was a hard-won battle, and then having to learn React/Vue/Svelte just to stay 'in the game' is too much for me. Excuse me if I'm biased here.
THAT is the fatigue part to me. I don't really mind learning new frameworks, cuz let's be honest, most of them are all doing CRUD operations and repainting the browser with new html. However, under the hood stuff that potentially arises with misaligned, packages, or configs...ughhhhh
It may as well be a foreign language to me, but webpack? Webpack is easy... To me.
Every environment of its time goes through a phase of build-specialist position, required for big projects. Webpack must be one of the worst so far though, it's in this uncanny valley of being unopinionated yet still requiring special operators and plugins for everything. It feels like a black box where you just can't be creative and compose things yourself, you always have to copy a template and find the magic justMakeItWork-option. No surprise really, since it's in a rather difficult position, integrating 3 major legacy technologies (css/html/js) that were not meant for it to begin with, add pre-processors like sass, typescript and static asset generation to the mix and you have more than 6 stacks to spaghetti together.
To be fair, while the hours of painful medium articles and gists research, the knowledge gained has given me a better understanding of Webpack, and I do feel more confident when taking on various tutorials which all have different approaches to fit the config to my needs. But still, as a newcomer to JS or someone in OP's position, the build game is certainly a lot more complicated than your command!
....btw, I have no idea what your command does/says :D. Linux (Ubuntu) CLI syntax has been something I've tried to improve on over the years.
I'm being honest here -- there are things you need to learn. You may not like them at a beginner or someone new to the stack, but they are here as industry standards for good reasons (which I won't go into here).
By the way, JavaScript is not necessary a language as "easy" as you think is. I have seen plenty of bad code written by professional software engineers. Seriously, you need to put a lot of effort into becoming a good front end developer.
These frameworks aren't meant to do what basic DHTML did back in the day. Those use cases are still served just fine by basic scripting or serverside interactivity.
What these frameworks allow are entirely new classes of featureful client-side applications (think Google Workspace, Maps, Earth, dashboards, games, sketching programs, photo editors, etc.) that would be HELL to write in vanilla JS.
If you're not building something like that, nobody is forcing you to use those frameworks. But at a certain level of complexity, those frameworks are worth their tradeoffs. Beyond that, at an even higher level of complexity, they become necessary... or you end up writing your own framework.
The reason these see such adoption isn't because devs are getting easier, but web apps are getting orders of magnitude more complex than back in the day.
I don't think the bar to entry to has necessarily gotten much higher; rather, the skill ceiling has increased a thousandfold... you can still be a basic JS dev to add a basic form validation and submission or whatever, and you don't need React for that. These days vanilla is plenty powerful for simpler use cases. But you can't easily scale that up to the level of modern web app interactivity. Or if you can, well, build it and show people and see if you succeed in convincing them "this is better than Vue/Svelte/React/Angular". People are always saying that, but I've yet to see a complex web app NOT written in some sort of abstracted framework. If you manage to do it, it would be very impressive and way more convincing than just saying "frameworks are unnecessary" -- because as far I can tell, along with thousands of others of web devs, they are not.
Well that was rather during the 90s, no? Like a decade before HTML5.
That was what it was called when I first started using JS in the late 90s with IE3 or 4 IIRC.
I went into js/ts because I wanted to create something that I can interact with graphically, I don't really care about DOM.
Worked out for me mostly:
https://aperocky.com/cellular-automata
These are built with typescript and compiled to js, with HTTP/CSS being static. And basically no framework usage. All of the complexity are essentially the simulation themselves.
I recently started to work in React for some work stuff, and I just hate it. Actually, both the "class oriented" and the newer "hook oriented" versions just suck. They amount of abstraction crap that get over a website is amazing. And Redux with the dispatch state change ... Angular is a bit more sane but still similarly bloated.
You need to look at ES6 as a completely new language, almost completely unrelated to JS. Once you learn it, React is easy - and genius in its simplicity. I can't imagine building even a medium sized webapp without some way of building UI declaratively. Maintaining a classical jQuery / native JS webapp is a nightmare, while these frameworks break up the problem into manageable pieces.
Highly recommend biting the bullet and learning one of them, it really is worth it (not necessarily React, there are lots of others too).
I designed it to be a natural transition from learning the fundamentals of HTML, CSS, and JavaScript into full-blown, component-driven UI development. Dirt simple API, no syntax tricks, no specialized knowledge. Just plain ol' HTML, CSS, and JavaScript organized into a system that's more productive than standalone files.
It works on its own in the browser or as a part of a full-stack framework.
Eventually, the original guideline of HTML for structure, CSS for styling, and JavaScript for interactivity started to not really make sense anymore for many websites, because as pages became more interactive, the lines became blurred. If you look at a site like GMail, where does the page structure end and interactivity begin?
With large parts of a page being interactive, it becomes difficult to manage all the state involved, especially if it’s a “live” page that updates in real time and may have several people viewing it.
Frameworks were introduced as a way to manage state and allow websites to re-render efficiently without hard page refreshes.
It's a history of one decision after another, made hastily, often in anger, and it's how we got ... here.
But most sites aren't GMail. Frameworks and typescript should still be the exception, and the rule should still be independent, modular libraries like JQuery.
People always say this but it's so hollow. Most sites aren't Gmail, but we're not building most sites. We're building applications that work in similar fashion to Gmail, thus need similar stuff like all these frameworks provide.
"Oh but everyone's using React to build their blogs instead of writing new posts for them and that's overkill"
Let me stop you before we get to this point. People use their personal blogs as a way to test new concepts they want to learn, so of course it's gonna be over engineered to hell.
And JS shouldn't be exceptionally bad but here we are, and people use TypeScript as alternative to stay sane.
I agree that modern web development comes with far too much complexity on average, but people started adopting those frameworks for a reason. The web is kept backwards compatible with obsolete standards which have been created in a different time for different purposes, and at some point it becomes easier to build abstractions over that. For example TailwindCSS adds another "compilation" step and configuration file but in return makes styling much more tolerable than standard CSS. Is it necessary? No, but when you build a large website all those little things add up.
My emphasis added.
There are still absolutely tons of sites for which the classical model works fine, and indeed works better than React at al, because pages load faster and behave more normally.
Some of those sites are now built with React et al anyway, for some bad reason (cargo culting, resumé-driven development, etc). But still, most are not, i suspect. Classical web development is still a very useful skill.
However, i suspect that although a majority of web sites don't involve React et al, a majority of web development jobs do - because the fraction of sites that are complex enough to need React et al also need a lot more developers!
(a fact i think is fun: a majority of stars are in binary or multiple star systems, even though such systems are a minority of star systems)
Ouch! As a google mail theft victim, "right in the heart" :(
> efficiently without hard page refreshes.
And completely destroying the "Back-forward-refresh" functionality.
There certainly is a decent subset of web development work where HTML/CSS/JS is still reasonable and viable, but it tends to be less complex, and low-code/no-code tools like Wix or Retool are quickly taking over that space.
I was not recommending Wix, and obviously there are plenty of downsides to using something like it. The fact remains that it has captured a lot of the market that would have used vanilla HTML/CSS in the past. That is what the OP was asking about.
As a backend dev who can do a bit of traditional style frontend, I fail to see the need for all this complexity. Most apps are running same database queries and displaying it on a webpage.
https://github.com/mdn/web-components-examples/blob/main/pop...
PHP was always a anything goes, Rails never impressed me having used AOLServer and being part of a team that created a similar architecture with TCL (Safelayer mention above, the founder of that startup created Outsystems), express is basically a servlet engine in terms of features.
Every time I talk to developers who use frontend frameworks, I challenge them and say: Let's sit down and build the same application. You build it with React or whatever, I build it with plain JS. Let's see which one is leaner and more logical.
Every time the answer is the same: The benefit of a frontend framework will not become visible in a small app. Only in a big app.
Then I ask: Ok, where is the cut off? What is the smallest app, where React will shine? And I never get an answer.
When I see React examples like this calculator ...
https://github.com/ahfarmer/calculator
... which use 70 files (without dependencies!) to build something one could do in a single HTML file, I am afraid that those "big" apps the React proponents talk about will be very big when implemented with React.
Leaner, yeah, I'm certain a vanilla app will produce less KBs. What about dev time? I've been writing JS since the late 90s and I'd never use vanilla for anything other than trivial projects, quick tests, etc.
More logical, that is 100% subjective.
> Ok, where is the cut off? What is the smallest app, where React will shine? And I never get an answer.
Of course you won't. It's an impossible question. Could you say with certainty at which point it's better to use or not use a framework? (any framework with any language) You can't.
Once you're deep into the swamp you may realize you should have used a framework... but it's often not obvious a priori.
> which use 70 files (without dependencies!)
Honestly that's kinda ridiculous. You could build a calculator with a single file and a couple of components. This is not a problem with using React or any other of the modern libs but with that particular programmer.
Yeah I'm trying to figure out how someone could possibly reach this number of files if you're not counting dependencies...
If I make the app with the explicit goal of having as many files as possible I can think of:
~6 config files and dotfiles. Maybe make it TypeScript so we have a tsconfig.json as well and maybe we'll have a README and LICENSE as well for good measure
In our public folder we'll have the index.html, a _redirects, robots.txt, a favicon, logos of different sizes, a manifest just in case, a sitemap because why not. Maybe a dozen files in total?
But for the actual source files? index.tsx and App.tsx (I usually make these two the same file). Maybe we're keeping our jsx and css in different files so let's just double the number of components by 2. I'm struggling to think of why this might have to be more than one component but let's just say it's 2. So 4 files in total. Let's even say there's a custom hook for some reason so that gives us another file.
That's like 7 files for the source code if we really stretch things out. Maybe you're one of those people that likes to have separate files for your routing or maybe you have some Layout.tsx business going on. Still can't imagine it stretching passed 10 files.
I'm up to 28 with a ton of rounding up...
I don't like the trend of using React to build a brochure level website with near zero ui interactions or api calls, it usually ends up bloated and a pain to try to split code, reduce bundle size, etc. for no real gains.
On the other hand, when I work on a complex stock brokerage dashboard with tons of data, tons of fancy ui that needs frequent updating, and a massive internal state with tons of user data and stock data (also being frequently updated), React is a pretty good choice.
One of my other sites is a legacy property with all UI powered by a single 6000 line jQuery and javascript file. It's very easy to break something without realizing trying to make changes there, so people keep adding new stuff at the bottom to minimize potential breaking changes. Definitely not the ideal vanilla JS setup but it isn't a good fit for the organization's needs.
At the end of the day, react is javascript and you can make any react site with plain javascript... but it is sometimes a useful abstraction for highly complex environments with many people working on them.
If you build anything semi-complicated, you’ll build your own declarative framework.
And maybe you can be happy sitting next to your pond, so long as you never see an ocean. Maybe when you meet people who tell you about the magnificent oceans they’ve seen, you figure they’re just exaggerating what it’s like to see a pond. “Ah yes, I remember seeing my first pond,” you chuckle. But somewhere deep in your brain, there’s a little twinge of doubt.*
Of course some sort of framework will naturally occur as a project grows.
If the cutoff is something like 10 years, what would your response be?
In a regular straightforward program you apply a change and read it back only when it is needed. Even if that change is cached/computed/transformed/etc, there is only need to observe it when your program execution comes to that part.
In a ui program after doing a change you have to somehow update all the relevant elements/controls that are currently visible on a screen, i.e. replicate the whole state of a program into a graphical context at once (regardless if html or not). This process has associated costs and is pretty error-prone if not addressed systemically. All these frameworks spin around some idea of optimization of it. Since it can't be done without tradeoffs, they invent new ways of thinking about a problem, offloading parts of it via methodological contracts to a developer, who pays their half of the price. Different developers have different opinions on how high the price should be and which trade-offs they should take.
Is it worth it? Sometimes yes, sometimes not really. In my opinion, ideas behind some frameworks are useful by themselves, but in general all this tends to become more religious rather than technical. E.g. if you weigh what "cost" is or how error-prone the straightforward approach is, you may find that for some cases it doesn't really matter.
(Client Authoritative State) Angular 2.x/??? => RiotJS/Bootstrap =>
(Server Authoritative State) Blazor/Bootstrap => Custom/Vanilla
The Angular and Riot apps were a nightmare to maintain long-term. We sign contracts with our customers that are 5+ years long, so having autonomy over this sort of stuff is critical. The rate of change with these frameworks was too much to deal with, especially at our scale of <10 employees.The big solve moving to Blazor from RiotJS was keeping the state on the server and being able to reuse existing C# codebase to manage UI. This continues to be very productive for us. Server-authoritative state is the answer for keeping complex UIs on rails.
We still have quite a few interfaces on top of Blazor, but those aren't really a pain point for us (at least until Microsoft does what they usually do in a few major versions...). The biggest catalyst for moving from Blazor/Bootstrap to Vanilla was 2-fold: On one hand, the power of modern web APIs, such as CSS Grid, eliminates a large reason why you need a 3rd party layout system in the first place. On the other, we realized that dynamically updating the DOM using a 2-way web socket setup is actually not that complicated or scary, assuming you have well-scoped requirements and aren't afraid of javascript.
For hand-rolled vanilla, the way we sync the DOM is with a simple 2-way web socket protocol where the server has a dictionary of elements per active client, and hashes of state are used to detect required updates after client events are processed. No shadow DOM or any of that crap. We just blow it all out and redraw on update. None of our UIs has enough elements to justify all that extra complexity right now. We could easily iterate into several directions if we needed to over time. The key point is that we understand 100% of our stack. Every line of code makes sense to us. At no point do we have to worry about someone pulling support or shifting their framework in an adverse direction.
Finally, we also have major security concerns with vendoring out anything, since our product is used - in part - for in-branch banking. The hottest PII you can imagine flows through our web app every day. Being able to tell various CTOs that there is no supply chain risk with our web UI is a very fun hat trick for me.
Meanwhile, that vanilla app will just keep working in perpetuity.
Don't get me wrong, it's perfectly possible to create spaghetti in React, but it just makes large codebases so much more manageable, and the tooling and ecosystem around it is massive.
Typescript with React and a bundler, linter etc. is just an amazing developer experience, compared to the mess those of us who did front end development in the past remember.
What you're saying is similar to saying "I don't understand why someone would use Django, can't I just use the python http.server for an API and psycopg to connect to postgres?"
The answer is yes, you can do that, but over time you'll find that there are pitfalls with a bare-bones approach that are easily avoided by using higher-level frameworks. Mostly the spaghetti that someone else mentioned, but also getting caught up in technical details that the frameworks have mostly already abstracted away.
I hate this.
So to do anything that needs state (think google maps, or a responsive website) you need to either build or buy a way to manage that state, while working inside the confines of HTML/HTTP.
In many ways you can look at react, vue, etc as javascript applications that use HTML/DOM to render. The problem is that they don't really see themselves like that, so the way they present stuff is sort of fucked up. And even after all these years the DOM handling stuff hasn't adjusted to the reality of web 2.0...because presumably the devs want to keep backward compatibility with hand-written css/html/js.
The DOM is another one of those hacky things that survived and thrived.
If browser makers, the standards people, framework makers, and web devs got together, they could theoretically simplify a lot of this shit going forwards, but they don't because it's too hard. Instead, we have these sort of layers of bullshit that live forever.
- adding interactivity to a web page vs building an application. Those are not the same thing, and what you read applies to the first
- there's a widely accepted belief that vanilla js is not suitable for building apps. I don't buy into this belief. I have a built networked Scrabble game with vanilla js. Both the backend and the frontend. This simplicity allowed external contributors not well-versed in the modern web stack to contribute. I also was able to enter the code of Pianojacq (from jacquesm) [1] and contribute quite easily because he also chose vanilla js. This simplicity is very valuable, and lost with modern framework, and nobody is really concerned about this.
I've done some React development, so I know my way in a modern app. I've also contributed to a frontend written in Vue. I think they solve problems but bring complexity to the table, in particular the tooling (bundlers, minifiers, etc), the dependencies and the debugging being much harder.
It seems DOM manipulation through native browser API scares many people, but when it's what you are familiar with, your usual "framework", it's manageable. You need to be disciplined to avoid things getting messy (a discipline frameworks partially enforce), but I really believe you can go far with vanilla js.
I believe React & Co are often picked to ease beginners' contributions, but they actually do require expertise. I'd rather touch vanilla js code from a beginner or an experienced developer than a React code from a beginner.
It's a matter of taste. Vanilla JS has the taste of fresh air to me. It's zen. You write the code and it runs. No tools, no slow compilation, no minification that complicates the debugging. Minification which is only useful because with those frameworks you bundle an awful quantity of code in the first place. Yes, source maps exists but they don't do everything.
But today you won't have access to the whole ecosystem of existing React components with vanilla JS. It might be a curse or a benediction.
In my 20 years working on the web I’ve found that a lot of styling libraries and tools like Bootstrap and Tailwind are great for getting off the ground quickly with a passable UI, and there are benefits for large teams to have a shared syntax and coding style that is well documented which these provide out of the box. But when it comes to overrides and general customization they can lead to people writing exotic selectors and using !important.
People often get frustrated with CSS, especially when the page loads and things start to interact. I’ve always found that less is more with styling and I’ve fixed more problems in my career by removing and simplifying style declarations.
CSS with variables, (and soon native nesting of selectors), animations, pseudo classes, and pseudo elements is quite powerful on its own. As long as there’s internal documentation for code styles and encapsulation of classes to components (even outside of a JS framework/library) its very scalable.
Absolutely agree re: depending on Bootstrap. Unless you're heavily leveraged in BS (no pun intended) either cuz 1) you're at an "early" phase in your product or 2) you've bought into yet another framework and are stuck with it :), you should start creating your own scss mixins to encapsulate these components.
My personal fave is to use scss w/ bem. The naming conventions coupled with nesting selectors also help real well to create long class names without having to type it all at one time
They do, of course, add their own wrinkles, but at the time of adoption ostensibly the juice is worth the squeeze--at least for whatever real-world challenge a given team (or the broader dev culture) is facing at the time.
---
I'll still use pure HTML/CSS/JS for client projects, depending on the context. Usually for static sites or interactive UI/UX prototypes, both in freelance and day-job (agency, bigcorp) contexts. So far, folks are very happy with the outcomes, but I do vet the fit first. :)
In other contexts like enterprise/SaaS apps, Shopify builds, etc. I won't insist on no-JS or avoiding React/SPAs, as much as I'd secretly like to, but I will advocate for self-hosting and minimizing 3P JS dependencies where we're not necessarily gaining a huge increase in capability in exchange for dev convenience, etc.
It's a balance.
There is the document web - in which HTML/CSS/JS is more than sufficient.
Somewhere between Web 1.0 and Web 2.0 we started experimenting with delivering application experiences to a web browser - arguably an abuse of the document web. This is the application web and it is a distinct use case. HTML, CSS, and JS on their own provide a pretty poor application development experience. At the very least, building a full application in HTML/CSS/JS is non-trivial. Rewind 10 years and many of the tools we take for granted on the backend were missing from web development, notably composability and dependency management. Scaling UI work up to teams of dozens of engineers is difficult. Companies with multiple UIs have a hard time re-using code between those UIs.
Tools like React, Storybook, npm, and Webpack are addressing that gap. If you don't use them, given sufficient time and growth, you'll end up with your own patterns trying to address similar gaps in your code base.
Arguably the industry took a pretty windy and awkward path to "on-demand sandboxed applications delivered over the wire," but that's just what happens with incremental development I guess. We started with a web browser and the document web, abused it to deliver some interactive applications, found it was "good enough," and then pushed it as far as it could go. We ended up at a local optimum. There are likely other optimums out there.
Not acceptable if each person working for 2 years builds his own abstractions that new hires have to learn - but you make it easier by using framework and hiring devs for that framework.
Not acceptable if you would have 20 of such teams and you would have to have UI/UX standardized.
Frameworks also establish a common way of doing things like tracking state. For example, in vanilla projects, one developer might implement it in a unique way that no one else understands. You want to work with code that works well with multiple developers on larger projects.
It's still fun and interesting using vanilla for personal projects. I built a bunch of apps with just a CSS framework and JS was vanilla. (my apps: https://lewdev.github.io)
Frameworks are needed for web apps, especially single page applications (SPAs), if you just want to build traditional page/document based sites the traditional methods work just fine.
However SPAs is where the money's at for developers, so developers tend to abuse it due to resume-driven development (RDD) in order to get themselves into better paying positions/companies.
That's why tutorials and articles are all about frameworks now, just follow the money.
Certainly, not building a website. MAYBE building certain kinds of apps, like a game or a paint app (see: most action is truly on the client-side).
---
I found a simple stack that is super-productive & efficient: https://tailwindcss.com + https://htmx.org.
This is, IMHO, the best way to do "normal" websites, even the ones some are tempted to get nuts with stuff like React (eCommerce, blogs, chat app,...).
The best is that it actually embrace the web as-is and not requiere anything to degrade correctly.
These frameworks bring in concepts that we take for granted in most other platforms.
More specifically: When I "do web," I prefer generating HTML on the server. Working with text that way is very simple, but the paradigm breaks down when the page needs to update itself from Javascript.
Javascript+html+css alone isn't nearly as powerful as the kind of UI tooling that I'm used to for Windows/Mac/iOS/Android. That's where the frameworks come in.
The reason why they change so much is that so far, no one's really come up with a good one. I personally think we'll get there if we can replace HTML, because that's the real obstacle. For representing a document; it's really cool, but for doing true UI, HTML just makes everything over complicated.
I don't use React. I learned a little bit of Vue. I'm definitely not an expert, but I think there are (at least) two problems that they solve: consistency and reusability.
Consistency: I think the hope is that if you're a React programmer and you see a brand new site written in React, you'll understand it, whereas if it used vanilla JS, it might be written in any number of ways.
Reusability: if you start writing your own reusable functions in vanilla, you'll eventually build your own React -- it's the build vs. buy decision.
Same goes for HTML/CSS/JS, in fact, CSS and JS are the answer to the limitation of HTML and static page serving which was the vanilla www. As for your question, I don’t see HTML/CSS/JS going anywhere, they are the building blocks of web development and are written as such.
And you lost me.
Is it possible to write reusable JS/CSS/HTML? Yes but the overhead is very frustrating and you will quickly find yourself building a custom framework to manage everything. Best to start with a framework from the start if you plan on having rich interactions. The speed at which I can move in VueJS is nothing short of amazing and the amount of reuse I get is extremely high, all without me having to manually manage a bunch of files/includes. With 1 TS import I can get all the HTML/CSS/JS for a component and safely use it in another component. At a minimum that would take 3 http calls in "vanillaJS" to fetch the html/css/js that I would need to maintain and update myself. SFC's are a game changer. Sure the browser might eventually support what I need but by that point I have no doubt that VueJS (or similar) will have lept further ahead.
It's the same reason I jumped on the 6to5/babel train early, it let me write my code in ES6 but still deploy to older browsers without waiting on everyone to upgrade.
At this point you're building a crappy version of a module and package manager, but all by yourself, nobody else is using your stuff, and you can't use their stuff either because it's not in your bespoke format.
All of the examples and concepts here are just inter-project related, but this applies within a project all the same.
We call out to libraries when doing things that are better handled via a library.
Guess what, when you use a bespoke solution for common tasks, you end up with something that blows past every other competitor's benchmarks, without even trying.
e.g. take a look at Benchpress, our templating engine: https://github.com/benchpressjs/benchpressjs/
It's similar for CSS with the added twist that it's a fair amount of work to get something non-hideous. Much better to start with something reasonably good looking and tweak from there.
The larger a code base gets, the more complex it can be, and frameworks help abstract ideas (like design systems), rather than having to repeat component code, css, each time it is needed. Also, if more developers are being added to the code base, the scaling of a project can get quite large. We have over 50 developers working at my company coding on the website.
Security is another. When updating a list of items (for example) from a fetch, vanilla js will require direct modification of the html, whereas a framework like React will handle that, with best security practices applied, as the code has been written and production tested.
I'm not going to deep dive on language features, can be quite subjective, for example how great Typescript is (compiler errors > runtime errors), or how SASS fills in a lot of missing features for CSS, etc.
I think some websites could be done in vanilla JS/HTML/CSS, but as the site scales, I feel at some point a developer would build their own framework to make things easier and streamlined. It's what developers do.
For my own project this is great - I have no deadlines, and half of the process is me just enjoying writing the code. For an existing company the demands are different. Not only are there time pressures, but aligning on something like React means you're introducing convention into the code. Hiring people who already know this convention is easy.
Vanilla js, even with webcomponents, just isn't quite there as far as convention and speed go, and there isn't a rich community around it. Is it perfectly able to do the task at hand? Absolutely, but at a price most companies aren't willing to pay. React is the easier of the two.
(In before people say, "but that's all I need for my blog!" Fine. go ahead and do that then. I'm talking about international huge scale applications)
What you'll do if you stay the purist and need to implement aformentioned services is that you'll eventually end up with some sort of quasi-framework, but bad in the sense that only you (or perhaps your team) know how it 'works'. With most frameworks there are at least opinionated ways to go about implementing all these things, and you can find other teams and consultants who speak this 'language' so to speak.
Being a purist is fine, but it really grinds my gears when people assume vanilla is ALWAYS the solution, and it can 'easily' be applied to things like e commerce shops, huge shared tools, or big social apps. Hint: it can't, unless you like a lot of pain.
---
We are building SyncHTML.io to counter that.
Try at https://sy.ht (press up/down arrows)
See how we set ourselves apart https://efn.kr/b/sync#new-playground
---
Web standards are unbeatable when used right.
They are not used right most of the time.
---
See 2 custom elements done right™: (The /?s at the end is significant!)
1. zero-md: https://md.sy.ht/?s (just press up/down arrow keys)
2. WebPDF.pro: https://pdf.sy.ht (view); https://pdf.sy.ht/?s (edit)
(The WebPDF.pro elements are served from an unoptimized server. Takes a few seconds to load.)
When I go to https://sy.ht, I see a clock animation on the right and a blank editor on the left. I tried arrow keys and nothing happened.
Got ERR_CONNECTION_RESET from https://efn.kr/b/sync#new-playground
What are you sharing? Is this a codepen-like thing?
This is what I am sharing: https://sy.ht/yt (YouTube video showing what this is about.)
In a native lang there is are near infinite choices to make in implementing a solution and no two developer’s native code typically looks the same. Jumping into a vanilla JS codebase can sometimes take more time because you have to discover and understand the choices the developer made. The code is highly configurable but lacks a common convention.
With a framework, some of those choices have been made for you. So, jumping into a framework codebase is sometimes easier and simpler for those that understand the framework. The code adheres to a public convention at the expense of being less configurable.
Folks open-sourced their libraries, others contributed, and we eventually wound up with frameworks.
The distinction mainly is in the apps. Yes, web apps almost always use a framework like React now. Others have already explained the whys.
However, it's still possible to do webapps the traditional way, with the server-side approach, adding only a little interactivity via JS - techs like LiveView and HotWire: https://hotwired.dev/
javascript used to be awful. Using JQuery was more or less required to have a decent API and not have your entire app full of polyfills. Those days are behind us, but the precedent remains.
Some javascript APIs are still pretty bad. Fetch and XMLHttpRequest are both really warty in their own ways, to the point where you're probably writing a wrapper function. Common-enough collection operations are missing, you'll need to write some sort of utils file. So you're definitely going to want at least some sort of small library for the missing stuff.
The DOM forms a parallel, persistent tree to your application state, and you need to manage the relationship between that and your app. Parallel state trees just always suck (I've also dealt with them in Box2D, some game engines, SVG renderers...), it's probably an antipattern. It's not that big of a deal for a small app, but for larger ones it starts getting hairy. And it certainly feels like you should be able to write a better API easily enough, but because the problem is that the entire DOM is based on a parallel state tree model, your wrapper library ends up getting large before you know it.
There are good technical reasons to use some sort of build system for your web content. Concatenating and minifying all your javascript helps a ton. But to do a really good job of minifying you basically need a whole compiler, and at that point you might start pulling in all sorts of clever transformations that seem like a good idea.
Just to reinforce this ... this is the case even with native desktop GUI toolkits. Take the example of GTK. You build a model for a tree/list view using the "nice" data types GTK provides. In Gtkmm (the C++ bindings) it's even easier and actually feels very idiomatic.
However, if you already have a model data structure somewhere in your code for other reasons (for example, your "backend" code isn't allowed to use GUI toolkit objects or APIs), you now have parallel state trees, and they suck just as much here as anywhere else.
I once inherited a project where the front end was split between like +20 different react projects across that many git repos which we really had to twist the arm of the original developer to get access to. That's definitely an example of doing it wrong.
Building highly stateful / interactive web apps. If your web app is sufficiently complex enough then your vanilla js solution will just become an undocumented framework in disguise. When you build a homegrown system that manages components and their lifecycles (reacting to state changes) then you've written a framework that no one else has experience or knowledge of.
> What makes the trade-off of all that extra complexity and abstraction worth it?
Interactive UI's that react to state changes are hard to manually manage as complexity increases. Your UI and state are connected by an undocumented large state machine. These frameworks essentially allow you to define how your state, in any shape it may take, should be reflected in the UI (DOM).
> Aren't HTML/CSS/JS perfectly fine and time-tested tools for web development on their own?
Sure, but all of the frameworks are written in JS and you write plain JS to use them. You might use something like JSX or TypeScript for convenience, but these are turned into plain JS. They're also not required, they've just become standard because of how convenient they are.
First I wrote a little 'RTS' game in Javascript where the player writes code for the units in game and runs the code in the browser. But the player/programmer needs more info about the game's state. Which means I need dynamic html components to display the changing state of the game. Easy enough, I used a lightweight library called slim-js to give me the functionality I needed minus the ugly boilerplate of the Shadow Dom. But now my dynamic components were re-rendering every single frame, since they were tied to a callback that was triggered when the game re-rendered. Ok, I'll just save the state of the game into a map and only update when there's a missing value or a new value. But all of this state management and custom component logic is overhead that makes the page harder to maintain.
I also wanted to use typescript to make sure I was passing the right values back and forth, which means transpiling every time I make a change. I also need to serve the index.html with a webserver, so I can import ES modules. Http-server works well enough for this, but what if I want to add another page to my site for watching tournaments run on the backend?
It was a nice exercise to learn /why/ frameworks like React exist. Moving forward I'm definitely going to move to a React-based page since I'm already starting to outgrow my vanilla-ish stack.
Here's the game if you'd like to check it out: https://ai-arena.com/
Same with BackboneJS and Angulars of the past, and if society has taught us anything, it's that there always be a NEW and IMPROVED one-framework-to-rule-all the other frameworks.
Also, the state of JS in browsers are way more "consistent" than the IE wild west of the 90's and 00's, which was why jQuery was so popular. And that began our dependency on plugins to provide consistent dev codebase in between browsers. So if you REALLY think about it, it's the browser vendors' fault for why "vanilla" HTML/CSS/JS seems to have so much tooling.
In the end...figure out what you're trying to build, and know that if it gets too complicated in straight up HTML/CSS/JS, there's plenty of frameworks to help you organized.
I've used frameworks for twelve years, and covered most of them across various projects. I particularly like the direction of recent frameworks like Svelte and Vue3.
Unfortunately, because the web is serious business, all of that complexity became the standard for the entire ecosystem.
Just using HTML/CSS/JS is considered either regressive or niche. It's called "vanilla js" which only shows how utterly locked in to the enterprise paradigm javascript has become, when what should be the default needs its own genre identifier to differentiate it from "the norm."
Yes they are perfectly fine, dont waste your time
I wrote a complete warehouse management system. I wouldn't be able to accomplish this in a relatively short time frame without help of frameworks and libraries. Instead of using vanilla SQL queries I used LINQ. For UI, I used bootstrap, because it made it easy to handle desktop/mobile. For async calls I used old jquery because it worked well enough with .NET and was well documented. Additionally .NET allowed to scaffold models and identity.
I can write a site in JS/HTML/CSS, however, why? I would rather do things quickly with proven frameworks. Size of websites is less of an issues these days. There may be use cases for going pure vanilla but often not the case from a business perspective.
I did use Typescript without a framework to implement this ios calculator clone (https://getcalculator.app/) and it was not a bad experience at all.
I wrote about it here (https://mejuto.co/the-ipad-did-not-have-a-calculator-so-i-po...)
For most applications the extra complexity is not worth it. React started off as a simple library but now it has bloated with Redux and ReactRouter and Hooks and all that nonsense.
You can do plain HTML/CSS/JS development for most projects. Here's an example: https://github.com/wisercoder/eureka It uses a couple of 500-line libs, that's it. No complicated framework, and yet you will be more productive.
Anything larger, however, and using a library just makes things easier: HTML partials and helpers, nesting in Sass, and data flow and component composition in JS frameworks are just easier when a project is large enough.
Yes, HTML/CSS/JS are perfectly fine tools for web development. But just like it's not as efficient to use a hammer as a nail gun, using HTML/CSS/JS alone might not be the best choice if you're trying to build something highly interactive or if you have other concerns (e.g. a very large team that consistently steps on each others' toes on accident).
I'd encourage that you try to actually take HTML/CSS/JS as far as you can take them, if nothing else to experience the pain points of using them at high levels of complexity yourself. This can give you an appreciation for why frameworks do things the way they do. For example, routers are patterns that every framework dealing w/ parameterized pages eventually lands on because it's a pattern that makes it easier to manage page parameterization.
It can be argued that some frameworks land on seemingly strange or overly complicated APIs sometimes, but that's just the realities of engineering. We try to make the best decisions with the known information at the time, and then we have to consider maintenance costs after the fact. Nobody is perfect and sometimes we only see flaws in an approach through hindsight. There's also such a thing as using the wrong tool for the job. Frameworks usually have scope and an idiomatic way of being used. These indicates which use cases the frameworks are strong for, and which aren't.
Most self-respecting frameworks will have some sort of tutorial that you can follow to get a feel for what type of tasks they are trying to optimize for. Try them out to see if that's what you need. If it's not, that's ok, there are plenty of other tools that could fit the bill better. My recommendation would be to try different "categories" of frameworks. For example, React/Vue/Svelte are very similar in scope, so trying one should give you an idea of what all three are more or less all about. You could try htmx, or GWT or even jQuery to experience completely different flavors of "framework-ness", maybe one of those will "click" better. Maybe you'll find that vanilla HTML/CSS/JS is all you need after all, and that's ok too.
The basics of React are learned by 1-month novice programmers in 2022. You don't even need a build system (which is even setup for you with Next or create-react-app). At it's core, it's just a file which contains "super"-html that you can update state more easily.
(A) "SPA by default" and piling on layers of abstractions
to
(B) properly leveraging the web as a platform, and mentoring the browser instead of micromanaging it
...and the trend is finally starting to move (back) towards (B).
There's also a significant role played by the "document-based web" vs "web applications" paradigms' semi-dichotomy.
You'll see plenty of (frankly sophomoric) takes like "webdevs are rediscovering that server-rendering HTML is a good idea, LOL, sounds like PHP or my cgi-bin Perl scripts from 1999" -- which ignore the need for client-side interactivity and responsiveness and the profound changes in the capabilities of clients, networks, servers, languages, and tooling over the intervening years.
I highly recommend a close look at https://Remix.run and https://every-layout.dev (and probably https://Astro.build) for examples of frameworks and techniques that thoughtfully leverage the best of what's new as it continues to evolve, while being firmly grounded in from-first-principles foundations that enable creation of magic comprised of sane primitives.
I've been building and improving web-related sites and apps for a living since 1998, and without reservation urge anyone involved in webdev to read up on both Remix and EL's "axiomatic CSS". They provide a profoundly well-informed and -reasoned perspective that answer your question and help show the way forward amid all the froth and churn and nonsense. It's the signal in the noise.
"Child, you know your mad uncle Joe who lives up at the big asylum?"
"Yes Papa"
"Well stay the fuck away from frontend web development"
While I see the value of using vanilla stuff, the complexity of software requirements, ever evolving browser APIs and features and increasing ease of using libraries (i.e. date-fns, lodash, etc.) has definitely increased the appeal of frameworks.
They all ended up building some framework similar to react or angular. There is no other way to manage the growing complexity than to invent some “engine” and a set of rules.
So your question has the answer in itself. There is no “or”.
React _is_ HTML/CSS/JS, but organized for complex projects. And definitely not for any project.
I bet most of “js justice” warrior have never got their hands deep in really big uis
Grug try develop Notion or Google Sheets competitor, grug use React/Vue framework.
I’ve been lucky enough to experience development across many different types of systems over my 20-year career, and web development has come a long long way to the point that Vanilla development is viable.
Generally speaking, I prefer to spend my time solving problems, not reinventing the wheel with boilerplate. Using a framework like react aids me in that goal.
Components provide a better primitive by combining related css, html and js together as one unit.
This is not supported by native browsers, hence custom frameworks are necessary and better
The complexity of vanilla gets out of hand when developing web applications (websites that feature menus and tools and widgets and state that the user interacts with - think JIRA or Gmail or Google Docs, etc)
So I'm currently maintaining a totally static blog I build in Hugo. It's almost nothing but plaintext, one static CSS file, and some images. One time in a hundred, when I select a new story, the lightly-shaded background of the page blanks through white because loading a couple resources takes too long.
For my personal blog, for fun? That's fine. For most corporate sites? Unacceptable. Looks unprofessional. This is 2022; we're not using teletypes and command-lines anymore where the user can feel the individual bytes coming over the wire.
So to prevent just that one visual hiccup, I'd need to do dynamic fetching of page content and a hollow-and-replace of the content div instead of reloading the entire page when the user navigates around, but I also need to support direct navigation to the page loading the full page content, and I need to do this all correctly from Google et. al's point of view so search crawling doesn't break. And at that point? I'm definitely using a framework (probably with both client and server-side components). All because the aesthetic of the end-user has evolved and your page looks unprofessional if it navigates like a traditional '90s-era page.
That doesn't sound right to me. Why isn't the "one static CSS file" cached? It should load instantly because it's already in your browser and doesn't need to fetch anything. I've created/maintained static sites as well and I've never run into this visual hiccup you are describing.
im not nessecarily disputing this, but if so, they clearly are stupid, given all the crap they will put up with
At their scale, the cost is worth it; it's just business.
This is an era of ubiquitous 100mbps+ connections, CDNs, and edge-computing-two-hops-from-the-customer hosting. The whole reason we invented SPAs (bandwidth savings and latency) predicated on AJAX has been obviated.
We can return to serverside HTML/CSS and forms with no loss of UI quality.
When a choice is made to use a framework the choice declares the stakeholder(s) trust the framework to provide a better architecture than the assigned developers. How prolific a given group of frameworks become understates how little faith the decision makers have in developers to write an acceptable solution.
JS frameworks allow front-end developers to get around this limitation by rebuilding parts of the platform as a JavaScript application. For example, if you want to customize how navigation works on your page, you can either use the few, limited hooks offered by the browser (e.g., registering window.onunload callbacks), or you can make navigation an application concern by writing your site as a single-page app. There are plenty of things you just can't do with a framework-less multipage site (like animate transitions between pages) that are possible once you make navigation an application rather than platform concern.
I can understand why many enterprise teams choose to use front-end frameworks like React even when it would arguably be faster and easier to just use vanilla JS, as there's a risk someone may need to add functionality that is not supported by the native web platform. For personal projects, though, I use vanilla JS and HTML.
It still works fairly well on the relatively small scale if you just want to write a frontend app (i.e. simulations):
https://blog.risingstack.com/writing-a-javascript-framework-...
I tried create-react-app and it's basically on mimimal support, updates broke stuff, outdated deps, devs unresponsive, ...
What is the simplest, least likely to break, minimal dependency, live update tool chain for typescript, and or typescript + react?
80% of them will be amazed how easy it is. I bet 20% of those implementation each would cover 80% of application use case today.
This is not unheard of in languages that have an HTTP server and router built into the standard library (Go is the most prominent example here, but I've seen many node.js web services written w/o 3P frameworks). You could argue that the stdlib functionality is a framework, just not one that you need to install, but the same could be said of vanilla HTML/CSS/JS.
There is nothing like being on the lowest common denominator, but you can understand why browsers are not evolving past this point.
With their rise in mid 2000s, having a framework with which you could manipulate the entire dom real-time to reflect the state in the backend have been accepted as obligatory.
Whereas in reality, aside from the neat templating that frameworks like React bring to the frontend, there is absolutely no need for the majority of web applications to be able to send micro updates to the client like how it is obligatory for social networks or other apps that are heavy in user interaction.
The least thing that you would want to do when a user is going through an ecommerce checkout process is to manipulate the dom and change stuff that could distract the user from the checkout process, for example. If you need to update some info with the changing quantities in the cart or address, that could as well be done with simpler stuff like jQuery - considering that your site does not have such features that will cause your jQuery to bloat.
There is even less need in the majority of the web where only content is consumed - how much interactivity do you need for a news article at the guardian or even your local-news blog? The user will just want to read the article. He or she may not even bother to comment (and likely wont), and when they comment, you definitely don't need a full fledged framework manipulating the dom to post and refresh the comments section. HTML and the browser already sort that out.
...
The overall idea is sound, yes. A better form of presenting and manipulating the dom is a good thing. But, the bloated frameworks and the dependency hell that we created for ourselves do not look like the way to do it.
Corporations generally can ignore the majority of people and only concentrate on their target market. If their target market can be coerced into using SPA and other application based weapon design then that's easier and cheaper for teams of paid developers to do. If only because most modern web devs are trained to make such JS applications.
But everyone else, individual humans, institutions, governments, they should try to make their websites accessible to all. It's a shame that few are.
Component Frameworks give you more structure that organize the projects in more sane ways.
Maybe it just "seems" like they don't because so many people post about using web frameworks, and nobody posts about not using frameworks?
Adding basic features or fixing the many bugs we discovered every day took hours or days. Any refactoring took weeks. We had to invent new abstractions on top of existing abstractions to keep everything more or less understandable and maintainable. Just splitting the code into different files (like to achieve some sort of frontend MVC and avoiding to have 5k lines of code in a single file...) and loading everything in the correct order was a puzzle. Making or changing any kind of edit forms was a real challenge too and prone to just adding new bugs to the list. Between loading all the data in AJAX, adding an id to each input and filling every input one by one with jQuery by copy/pasting their ids from the HTML, generating the selects and selecting the correct option(s) and adding them to the DOM, dealing with all the buggy jQuery modules like date and time pickers and their own ways to initialize and return data, showing or hiding parts of the form depending of the selected options, extracting the new values one by one from the DOM with jQuery once the user submits the form, validating the data and toggling the classes of the inputs to "error" with jQuery and adding error messages at the correct spots inside the DOM, revalidating the data and formatting it and sending it to the backend, refetching the values just to be sure everything is in sync and updating the values inside the DOM again with jQuery by copy/pasting ids and classes from the HTML... We take all this stuff for granted nowadays because the frameworks do it for us but it was so artisanal back then.
Eventually I pushed to rewrite the app when Backbone.js came up, and we started using tools like grunt, and it was already a huge step forward. Then some years later we migrated to Angular 1, it was another big win in productivity. Eventually React came out and I started experimenting with it and I thought it was revolutionary. Its component paradigm allows to break the app into small manageable and reusable pieces and this makes everything simpler. And then Microsoft released TypeScript and now we have code safety and autocompletion on everything, including external packages. And we also have JS export/imports, fetch, async/await and so on... And tools to test all the logic and interactivity in our apps.
Nowadays frontend development is just so much easier than before. I can't believe that people who think the opposite have actually worked on any sort of real life big frontend projects in an enterprise environment (1 or several teams working on the same codebase, new non-trivial features to implement every day).
We have frameworks instead of static HTML because it is really complicated to make a website behave like an app and it takes a LOT of javascript. We started out with jQuery ajax calls and media queries. We moved on to AngularJS to start swapping content in the page in larger chunks and maintain state and code better. We've now moved most/all of the site functionality into Javascript via React to better manage caching and state of the application for the best performance and more manageable code.
The reason react was invented was to enable real time update of items on the page -- to update when someone liked your item, or send you a notification update instantly instead of polling the server.
It was the idea of pushing code to the webpage. So they made a component in javascript that updates in realtime -- the state or prop determining the content or how many likes the post had. However this ended up requiring a huge Redis instance which is also very expensive, so now they need to sell more ads. In order to figure this out they realize emojis on the like button allow people to choose a sentiment of their reaction to the content. Their ML uses the sentiment to group and sandwich ads between content the ML knows or thinks you will react favorably.
So for example, a comedy central ad will be shown after a meme or story that is similar or something you reacted Haha to because the advertiser's desired reaction is a Haha as well.
Thus the name React. Plus it makes that div/element/part of the page defined as a "component" in js that will update or "react" in realtime -- anytime they push an update to the server everyone viewing that page sees it change in realtime.
Essentially a combination of a push notification or pubsub and ajax request.
Honestly, when jsx goes out of style like it should because its idiotic, and gross, and a violation of those separations of concerns, it could just be an html page where you write a js function to add a realtime update to an id or class...
Svelte uses that style of approach to the DOM.
If you don't have a realtime data store like Redis or any type of realtime data streaming going on, React or any other component based framework is a waste of time.
The ability to update the page without reloading or building as a single page app is not SEO friendly unless you use SSR which you already would have created in your normal seo friendly html files.
also name your files consistently and clearly.
unless you need to change the page in realtime without reloading, react and these other component frameworks have no use case.
If you want a clean css3 framework to help build a web front end that works neatly in html5 check out Bulma.
Bulma.io
You are exactly right, the js developer scene is like a herd and people wanted to work at facebook or look smart so they learned it.
It's useful for making single page applications, however all framework interactivity can be written in normal js, so if you take your time you'll have much cleaner, unbloated code, yielding pages that run better and faster...
* not particularly impressive in terms of UI requirements
* likely took them 10x the amount of time it would have taken if they just used a framework
* doesn't make any API calls
* doesn't manage any/much state
* is composed of code that no one else would be able to easily hop into and refactor if working in a team scenario
We have frameworks instead of static HTML because it is really complicated to make a website behave like an app and it takes a LOT of javascript. We started out with jQuery ajax calls and media queries. We moved on to AngularJS to start swapping content in the page in larger chunks and maintain state and code better. We've now moved most/all of the site functionality into Javascript via React to better manage caching and state of the application for the best performance and more manageable code that leverages APIs for most of its data and content.
I have been programming for decades and used many different component systems on the web and desktop, such as React, Angular, Vue, WPF, wxWidgets, some more that I dont remember.
For projects involving several designers and developers, some kind of component model might be necessary to be able to easily reuse and integrate code. Also designers or backend programmers may not factor in the complexity of certain design or architectural decisions such as state changes that are supposed to cascade to other items on the page.
Since I am controlling all of those decisions, I can for example simplify so that either only state relevant to one small element is updated, or an entire tab panel is re-rendered. And then can ensure there is time to optimize the panel rendering.
With that amount of control, usually the extra cognitive load for the component system etc. seems to not be worthwhile.
But for example many years ago I had a complex web front end given to me on a shoestring budget, with subpanels etc. supposedly automatically reflecting every other type of state change that occurred. He insisted that I use a plain version of something called Knockout.js which did not have facilities for tracking and updating based on so many dependent state changes. Then he kept adding more and more panels and components, with more cascading or interacting state changes that caused bugs when I tried to manually keep them up to date.
So that was kind of a "setup" in terms of the architecture required of me by the contract and the design decisions and there were lots of bugs and was especially rough to do in a small time frame. At the time things like React and related state management did not exist or were not known to the client, who thought he knew better about architectural decisions anyway and so that wasn't something I had room to negotiate or in the budget to research.
You either need a good concept for handling all of these potentially interacting state changes such as what happens with component and state flow systems, or you do what I do. The whole design avoids it where possible, and when necessary I set it up so I can just re-render that whole section, making design decisions to avoid something causing annoying latency or other problems. It's a lot easier for me to do this stuff as a solo developer where I have end to end control.
Also one thing that has changed in the last several years I think is that Firefox and Chrome have gotten significantly faster at re-rendering HTML through various optimizations. So actually some teams may want to reevaluate complex state or component frameworks to see if they might be overkill.
Aeons ago I learned js with Mootools, so much so I thought in Mootools vernacular. Imagine my surprise when Mootools went away seemingly overnight and I couldn't code vanilla js to save my life.
I'm pretty confident in my ability to pick up new tools and tech (I'm probably too far into the "bleeding edge" side of the "how comfortable are you supporting new tech in prod?" scale), so I'm not overly worried about getting left behind.
I just recently had to explicitly build a "raw" JS/HTML/CSS app for work, and found myself missing the organization React overlayed on top of JS, is all.
Besides, my bread and butter is backend, so I can always throw my hands up and shove the work onto some web dev's plate if I ever do get left behind! :D
No react needed.
3 mins... or were you looking for a server-side component as well?