News for hackers. Stuff that matters.
Re:Conditional JavaScript: Only download when it is appropriate by bamboleo on Thursday December 17, 2020 @08:14PM (#25462652)
This is rather low-level and needs to be hardcoded by developers. It doesn’t scale.

What we need is ways to mark content as optional or offering it in multiple levels, that the navigator can pick from. This would be similar to how videos are served.

I also want to point out the Save-Data header which is a step in the right direction.

Re:Conditional JavaScript: Only download when it is appropriate by austincheney on Friday December 18, 2020 @12:18AM (#25464139)
What we need is competent developers who don’t require 10mb of JS when a couple of functions at less than 30kb (unminified) is all you need.
Re:Conditional JavaScript: Only download when it is appropriate by bamboleo on Friday December 18, 2020 @12:44AM (#25464255)
All you need is 30kb unminified; All I need might be a considerable amount of texture and code to run a 3D game.

Just because you only visit Hacker News it doesn’t mean that every website can do its job with an equivalent amount of JS.

The whole point of such APIs is to automatically provide the right content to people: Lightweight on slow connections, beautiful on the rest of them.

Re:Conditional JavaScript: Only download when it is appropriate by zinekeller on Friday December 18, 2020 @01:32AM (#25464454)
> All you need is 30kb unminified; All I need might be a considerable amount of texture and code to run a 3D game.

While I understand your frustration, I would certainly understand a web game loading more JS than, I dunno, some major text-oriented web sites where a similar page can be written with minimal or even no JS.

Re:Conditional JavaScript: Only download when it is appropriate by dspillett on Friday December 18, 2020 @07:21AM (#25466379)
> All you need is 30kb unminified; All I need might be a considerable amount of texture and code to run a 3D game.

This I think is the point. The requirements are different, but to look at many web pages you'd not notice.

Too many resources that could be relatively simple pages with some code to aid user experience, are becoming massive full-blown applications pulling in megabytes of code and supporting assets.

Your game requires that code and those assets by its very nature. The vast majority of web pages/sites do not, and can probably be just as beautiful without (if not more so, as speed and responsiveness is part of aesthetic judgements).

Re:Conditional JavaScript: Only download when it is appropriate by bamboleo on Friday December 18, 2020 @10:19AM (#25467886)
To be honest I don’t disagree with you. I really wish content was served raw with an optional interface, but the consumer isn’t willing to pay for that.
Re:Conditional JavaScript: Only download when it is appropriate by austincheney on Friday December 18, 2020 @03:49AM (#25465149)
How many JS developers do know, in person, that are skilled enough to write a game or any other fully fleshed out application? I am being critical because I am a JS developer and everywhere I look the criticism is well deserved.

You wouldn’t need such APIs if the developers didn’t shove so much baggage at the user. If the problem really is the result of competence then even the best APIs ever written won’t fix this.

Re:Conditional JavaScript: Only download when it is appropriate by tored on Friday December 18, 2020 @09:12AM (#25467226)
I think we have to make a distinction between web page and web application. Unfortunately many web pages today are written as if they were web applications.
Re:Conditional JavaScript: Only download when it is appropriate by umaar on Thursday December 17, 2020 @08:31PM (#25462766)
OP here, yeah the amount of website variations this could lead to (and don't get me started with CSS media features!).

I don't see this strategy being adopted by most websites, but I reckon it's a technique worth knowing about. I've worked on WebGL visualisations where the device RAM played a big role on performance for example.