Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JS is usually what kills performance on lower end devices. If websites were only html and css, my smartphone from 2015 would still be a functional device. I have yet to have a page crash due to too poorly written html and css.


It depends what you're doing with the JavaScript. This is like saying "C kills performance" because you found one slow C program. JavaScript can actually improve performance in quite a few conditions (even on lower end devices) by preventing full page reloads and such, which adds more overhead in the network, HTML parsing, etc.


If we're talking about saving bandwidth, JS can be useful, although JS bundles are usually heavier than their HTML and CSS counterparts.

I have yet to see an example where rewriting the DOM would end up being lighter on devices with lower-end CPUs and RAM than doing a full page refresh. Browsers already cache static assets, generally a page refresh only takes a second or two (on reasonable connections)


A common example is when you have a page with information and you want to load some additional data or details to display (possibly just a single line). Often times, a a simple AJAX request is faster, and it's also often better UX, IMHO. There are loads of examples of this, but people don't tend to notice when it works well and only remember the examples where it doesn't (like, say, the new Reddit UI).

The application I work on initially used to work completely without JS, but I let that go and now you need JS. It made everything faster, more performant (even on my shitty phone), and the code easier to work with. And it's just 770 lines of JS (+ jQuery, because I think it's just more convenient than dealing with the DOM API).


A great example of this: compare Sourcehut to GitHub or any software forge that requires JS.

https://forgeperf.org/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: