On the current typescript / anti-typescript internet drama I saw someone mention javascript without a build step.
Do you think we’re already there?
Last time I attempted it:
- there were too many libraries I couldn’t import
- JSX (using babel) had a warning saying you shouldn’t do it in the browser for production
- there was some advice against not using a bundler, because several requests for different .js files is slower and bigger than a bundled package
It’s doable and although I would best describe the dev experience as “ok”, it is improving over time.
Per your bullets
-
use newer module based js libraries, yes this is limiting but getting better support over time, and you still have to deal with issues cause by different library types when using a bundler
-
JSX will require a build step at some point, pushing that to runtime doesn’t improve anything. Instead I would favor lit html
-
probably true, but I would start without and wrap a bundler around the project when it becomes necessary, smaller projects will have a negligible effect. You should benchmark the differences yourself, and if you use es modules everywhere wrapping a bundler around it will be easy.
With the above you can get all the usual niceties too: hot reloading, lazy loading, etc
Isn’t Babel part of the build step? I might not be misunderstanding with what you mean by build step here.
In general, you probably can’t avoid a bundler for the browser without significant compromises on performance and developer experience.
I’m asking mostly out of curiosity, but I had a use case that I would like to completely avoid a build step. At work we have a very old web interface, that when I attempt to sell the idea of any major improvement the answer is “this is end of life, we are rewriting it”. But the rewrite will take a long time, and it is easier to make gradual improvements without introducing new tooling. This one is from the 90s, there the JS is in a folder and is shipped as is.
Does it still make sense to use javascript? I thought WASM would make JS obsolete and introduce web UI frameworks in other languages.
WASM’s biggest holdback is that it cannot directly access the DOM. Until then, JS will still have a prominent place in building anything rendered in a browser.
That’s actually a myth and real world performance isn’t affected by this. See this video from leptos creator which is one of the more popular wasm ui framework https://youtu.be/4KtotxNAwME?si=D_vWV1LPQI-C9j8G
The biggest issue is actually the size of the payload since you need to ship the entire app and language runtime.
It’s not a question of performance - it’s just the fact that you need to use JS to modify the DOM in WASM. Until there is access to the DOM from WASM, there simply will be a place for JS in nearly every web app and it’s not because it’s fast, it’s because there are still certain things just need to be done using JS.
My point is really nothing to do with performance and I agree with the video you’ve linked: WASM is fast enough today. Whenever you can truly stop using JavaScript, I’ll be the first in line. You can already use WASM and eliminate huge portions of JS - but for anything beyond a very simple UI, you always end up with something that needs to be called in JS.
Here is an alternative Piped link(s):
https://piped.video/4KtotxNAwME?si=D_vWV1LPQI-C9j8G
Piped is a privacy-respecting open-source alternative frontend to YouTube.
I’m open-source, check me out at GitHub.
The real answer to the question you didn’t ask is: just don’t involve yourself in internet drama’s.
Tell me instead, what is the problem with a build step and typescript?
Just use WASM
If only…