JS, Everywhere and Nowhere, all at once
Hey there! Welcome to the first biweekly post. This is going to turn the blog into an update / general tech/code blog (instead of posting once every few months or more.) So before we get into the topic, here’s some general site updates:
- Port all old posts to MD / MDX format and add them
- Add resume and started on misc. page
- Fix rss.xml not properly working
- Small stylistic change to blog list
Along with this, I’ve also started hosting open-source frontends, starting with Invidious. My main instance (iv.ggtyler.dev) went public on the 6th, and since then, nearly 50 users have registered. (Keep in mind most people don’t register.) I may host more in the future, so stay tuned. Also, if you’re from one of those instances, thanks for checking this site out!
If you’re a regular user, you probably didn’t even know. All you might’ve known is that these applications use a fair bit of memory: Combined, all of these apps use 5 GB, over 30% of a regular gaming system’s RAM (16GB), and over half of an average PC’s RAM (8GB)!
Now, why is this the case? Well it’s not like they want to purposely gimp your PC. I’m sure if most developers had the option, they would make it so it only takes up 10MB.
But it’s important to know that they may not have the option - in cases like Discord, they’re working with an app that’s been worked on for years. Throwing that all out to switch to a new framework or language is not only costly and a long process, but it has no real advantage besides performance.
With JS, the most you’ll have to deal with is async functionality. After that, you can do just about anything and easily. Oh, and there’s also cross-platform and the fact that you don’t have to remake your web app for desktop / mobile. That’s…probably the main reason to be honest.
But obviously, there’s downsides to JS. So what if we just… don’t use it? Like, at all?
This is the mentality behind crazy sites like this. Reader beware - there’s pretty much no CSS so you might have trouble viewing it.
Anyways, there are a few valid points he makes, but I think the biggest issue is that it’s heavily outdated. A pretty obvious question arises when you don’t use JS - what alternatives are there?
The closest one would be Flash, but not only does it require JS to be used at all, it also no longer exists. Maybe you can use PHP? But if you do that, you’re purposely gimping yourself since JS is objectively better, especially since you’d only be doing it server side. Just take a look at benchmarks between the two.
This is what makes the argument against it so interesting - The modern web is built on the three major languages, HTML, CSS, and JS. If you leave one of them out, you get a significantly worse site.
But I think we can all agree that using too much of one can be detrimental. So for any devs - try and find a balance between having too little or too much.
Take this website for example. The one you’re reading this on. It’s built on Astro, which strips all unnecessary scripts. And for the ones that do need JS, if it can’t run, the whole website isn’t affected by it.
As of writing, the only two elements that need client-side JS is the theme selector and comment section (comments are handled by a different library which is why it needs JS.) These two are not necessary for the whole website, so if you can’t use JS, no worries! Any other scripts that might need running (like Tailwind or the rss.xml generator) are done server-side.
As for Desktop and Mobile apps, it’s obvious the best option is to go fully native. But if you can’t do that, try something like Tauri, Neutralino, or NodeGui. These utilize native frameworks (such as Qt or WebKit) to boost performance - meaning you can still (mostly) use your old code from Electron or a website. It’s not perfect, web browser libraries on OS’s generally offload the resources into a different program, and NodeGui isn’t really for website ports, but it’s a far better option than rewriting everything. If you’re interested, here’s a comparison between multiple frameworks.
That’s it for this post. I’ll try and make these a bit more fleshed out in the future. Thank you for reading, and take care.