Hacker News new | ask | show | jobs
by NooneAtAll3 25 days ago
> Don't roll your own page scrolling.

browser should not even let the page see this action

> Don't roll your own link navigation.

browser should not even let the page see this action

> Don't roll your own text selection.

browser should not even let the page see this action

> Don't roll your own copy and paste.

browser should not even let the page see this action

I'm serious. WHY javascript code is even allowed to see all these actions of the user? We already loaded the page and rendered it - we users must already be free to do with the content as we please

13 comments

> WHY javascript code is even allowed to see all these actions of the user?

scrolling: used by games, maps, image viewers

link navigation: used for client-side routing (youtube/twitch, any website with a chat window)

text selection and copy/paste: word processors, spreadsheet editors, forum software, etc.

I'm not sure if your question was sincere or if you were trying to say that the web should not support these use cases.

Yes, you get to the heart of the problem - we turned what started of as a document viewer into a general purpose application platform.

Features paramount in a document viewer (broadly, "respect the user's local document viewing preferences") aren't desirable in a general purpose application platform.

A large number of companies/web developers don't think of themselves as offering the user a document to view on their own terms, but rather an "experience" that they want full control over (which means, most of the time: show ads and record user behavior).

If you're offering me a game, fair enough. But if you're showing me my hotel reservation or electric bill, I want a document, not an ""experience"".

Management wants you to want to have an experience.
nobody asked management.
And management asked nobody, and then did it anyway.

Your preferences are unusual. Most people either don't care or prefer flashiness over consistency.

It's something I've come to realise about the why the world is the way it is. Yes, to a certain extent it is because of locally maximal power structures and hierarchies propagating - but it is also because, taken as a whole, people are really just like that. A single politician may be corrupt, but that does not mean that most people, if taking their place, would not be as or more corrupt. Management sucks, yes - but that doesn't mean that most engineers who become managers wouldn't act the same way. You and I may prefer consistency over flashiness, but the majority of the world couldn't care less. So flashiness and "experiences" win.

A nerd podcast that I listen to was talking about shells and touched on Spaceship for zshell. One of the hosts talked about how having multi-line prompts became possible in the 90s, how it isn't new, but how packaging it up is new and now it's a trend for some people.

I'd previously found it interesting enough to try out for half a day. I've been back to my regular boring prompt ever since. Humans are attracted to shiny things. I innately understand why stuff like this is popular, even if I don't understand it intellectually / psychologically (I tried it because it looked cool; it didn't stick; what's different? I don't know, but I could talk a lot about it without really having a structured point.)

Yes, we've broken the intent of the browser. I'm sure there are better examples, but for me it was Google Maps. Oh my goodness, have you ever seen such a thing? It had to be impossible, but they did it. And from there, nothing was safe.

I don't think we can put the genie back in the bottle. There are things we can believe shouldn't be allowed in the browser. But breaking them would break things that people rely upon. Only pushing further to native apps (which I actually like on my desktop computer, phone is a walled garden) would make it possible and that's annoying as hell) could make it possible. Rambling. Just woke up. Please forgive.

On the extreme end, a web app can do all of its own rendering in a canvas with WebGL/WebGPU. Some apps do exactly this: Figma, Google Maps, Google Docs. Just to name a few. (edit: Earlier I claimed PDFjs uses canvas, but it does not. I was confusing it with Google Docs [1].)

It's a thing you can do. But it is very bad for extensions and extension developers for the same reasons that Java applets, Flash, and Shockwave were bad for the web. These apps are difficult for end users to customize. It's a real bane to tinkerers. And it's a shame that "view source" has slowly grown completely useless over the decades.

[1]: https://workspaceupdates.googleblog.com/2021/05/Google-Docs-...

I’m glad the era of Flash games existed. I’m glad it’s now possible to do all the same stuff in standard JS.
Why are HTML5/JS games so much laggier and buggier than Flash games?

Maybe it's not due to differences in the technologies used. I can imagine it's because less people make these games and spend less time per game to optimize it. Years ago there were thousands of flash games of each genre, a lot of them very well made, likely optimized for speed, pure works of art. Now I see the same 100 HTML5 games on all the sites, maybe reskinned a bit. I don't think we'll ever have in terms of quality as what was available on Kongregate or Armor Games.

I might download an old browser with Flash and some games. Years ago there was a collection of a few TB of Flash games, hope it's still around. Maybe some games that required network will not work, but most didn't.

Why are HTML5/JS games so much laggier and buggier than Flash games?

I’m not sure that’s actually the case.

Steve Jobs argued in his “thoughts on Flash” letter that Flash was too buggy, insecure and resource-hungry for mobile platforms. I worked on Chrome around that time and the Flash plugin was definitely one of the biggest sources of problems.

I think all the stuff you’re complaining about is to do with business models and not really anything to do with the technology. I reckon if Flash were still around we’d probably be in much the same place we are now. People would be complaining about restaurant menus being written in Flash instead of plain old HTML, etc etc.

I played Flash games 10-15 years ago on a 15 year old computer. I've tried HTML5 games on a 5 year old computer with a good CPU and lots of RAM, yet the experience doesn't compare at all. I doubt I'm looking through things with rose-colored glasses. I think I remember some games lagging, like if you'd spawned 1000s of enemies in a Tower Defense-type game, but that was very rare.

It's still likely that older games had more users so were optimized while newer games for Desktop don't have even 1% of that userbase since most people use a smartphone for simple games.

> scrolling: used by games, maps, image viewers

Out of curiosity, does anyone like the way Google Maps hijacks scrolling? I use a trackpad. When I scroll, I'd want it to pan around on the map, not zoom in and out (which always feels awful as a scroll action and never stops where I want it to).

Click-drag to pan doesn't feel nice.

It doesn't really matter anymore, since 99% of maps use is on mobile now, but this was always a small pain point to me in the past.

If you mean you prefer pinch/spread for zoom-out/in, I prefer the status quo with trackpad 2-finger scroll for zooming.

Pinching/spreading with index and middle finger feels unergonomic. Using my thumb on the trackpad would also feel unnatural, as would putting my 2 index fingers on the trackpad.

2 finger scroll is something you can "fling" such that the zooming motion continues even as your fingers have been lifted off the trackpad. Trying to "fling" a spread-out motion with your index and middle finger is an awkward motion, and of course in a pinching motion, your fingers would just crash into each other, so you'd have to lift before they crash. Pretty awkward.

On the phone, I often prefer tap then drag up/down (i.e. touch, lift, touch, slide) to zoom in/out with a single finger. It allows me to "fling" the zooming motion so it continues after I've lifted my finger. It makes a phone's interface behave like a trackpad's scrolling-zoom.

I never liked it either.

Panning by swiping feels so natural. That it breaks on a trackpad feels like a major oversight.

in my ideal world, the browser would ask to confirm "allow example.com to modify scroll behavior?" for all the potentially bad uses of javascript, like how current browsers ask you to allow microphone/multiple downloads/etc

does such a browser exist?

Because the web browser was burdened with the role of application host, and not just presentation of static content. There's no going backwards.
this is why the web stack feels like a car held together with duct tape these days. we collectively took the wrong fork in the road and doubled, tripled, and quadrupled down. computing in general is glorious when i feel like im working near computing and then i get to web app stuff and im like.. i dunno. sad. i get why we ended up where we did with web stacks but seriously what a nightmare
It's not a nightmare. It's the most popular gui/document/app platform for a reason. It's complex because it has to cater to many types of usecases. Name one platform that's better. I think people have tried and some might have even succeeded in limited slice of what web can do.

I have strong suspicion that it's exactly because of the “document” history why web is so approachable to creators, why there is “view source” and ultimately why you can hop from simple html blog, to CRUD app, to advanced CAD software.

rss
All of these annoyances and more can be blocked by StopTheMadness (available for iOS and macOS):

https://underpassapp.com/StopTheMadness/

This is one of the most useful programs I use every day. Works in Firefox too
> Sold separately

aaaand you lost my interest the moment money got involved

all these things are already fixable by browser extensions - what is lacking is exposing that in browser options and even making it the default

> all these things are already fixable by browser extensions

Which is what StopTheMadness is and does.

Do you not believe developers should be paid for the work they do? And if not, what do you think the majority of people on this forum do?
Not the GP, but to me this case feels like extortion.

I have the same problem with paying for extensions like Dark Reader, DeArrow, and any ad blockers. None of these apps should exist in the first place. They were created because the default state of the web is barbaric. And some developers have the gall to charge for the luxury of making the experience tolerable?

And yet, I've paid for every one of these.

Write your own extension, then, and make it cheaper than the others -- or free!
I think their point is the answer to a problem a gapping wound isn't cheaper or even free bandaids.

We already have regulations for accessibility and advertising. Yet they're weak in the US and rarely enforced.

> WHY javascript code is even allowed to see all these actions of the user?

Because the alternative is UI/UX Designers and Visionary Managers insisting on keeping Flash and Java Applets and Microsoft Visual Silverlight .Net++ around forever, because you can't do some things in the browser and We Need To Do Them.

Some things have minimal complexity that either lives in the language itself or in libraries. The Web has minimal bells and whistles that are either implemented in the browsers itself or in plugins.

Nobody “needed” the web to do these things. We decided that the effort and cost of making native applications was too great. I’d argue we went the wrong way given that even the same browser will exhibit slightly different behavior depending upon the underlying platform upon which it runs.
> WHY javascript code is even allowed to see all these actions of the user? We already loaded the page and rendered it

Nope we haven’t. At least not in a web application. At least not since the days Infinite Scrolling was invented. IIRC Twitter, for eg, only renders a partial list depending on the scroll position.

I once wrote a NER tagger, where implementing custom text selection allowed users to not stress about selecting the exact word boundaries when manually tagging 1000s of words per day.

I can probably find legitimate use cases for almost of these things in the list. While I agree with the broader theme of the article, this idea that the user agent should be a dumb display is not valid.

I found that most internet pages are greatly enhanced by disabling JavaScript in my web browser.
It depends. A lot of websites refuse to display some stuff without JavaScript, and of course online payments insist on JavaScript (to the point that trying to push through without it can result in strange errors and potential double-charges as you troubleshoot).
total disabling of JS is overkill

I mean, I'm all for for switching to Lua or smth (which is a slightly different anti-JS camp than yours), but the problem isn't in interactive (or even non-frozen) pages in general - it's in pages reading user actions that user doesn't expect/want to

And fingerprinting the user, and spying on their behavior, and showing them crap, and wasting their battery, and wasting their bandwidth, and...
It should be illegal for a website to hijack text copying, right clicking, or keyboard shortcuts like Ctrl*f.
No. There are already too many batshit insane laws trying to regulate the internet. We need less, not more.
Indeed, people talk about technical solutions to social problems but there is also such a thing as trying a legal solution for a technical problem.
Also: Javascript should not be able to touch the browser history. I know it's useful for some apps. But it's too prone to abuse and that API should be revoked.
my main argument against this has been reading books

I don't enjoy needing to "go back" 100 times, once for each page of the book just to return to f.e. search results I opened the book from

The Web is an ads platform with useful functionality as bait.

That's all there really is to it: Mosaic added image support. Investors got excited and asked if the images could animate, if they could record click data and credit card data, if they could add video and additional presentational elements. Holistic user experiences were secondary.

To move forward we have to accept that most of this wasn't an accident and it needs some breaking changes.

Applications like Google Docs would be impossible without each of the four things you listed being available. We had Google Docs that didn’t roll-your-own for each of the items in that list and it was called Writely and it was absolute dogshit (but super cool for its time) because those limitations were too extreme. And by extension it wouldn’t make sense to have Chromebooks as a category of hardware, because web software could never compete at a feature parity level with native software.
> Applications like Google Docs would be impossible without each of the four things you listed being available.

I was already in favor of banning it. You don't have to keep trying to convince me.

Okay, snark off. But as someone who dislikes the proliferation of "web apps", I'd be perfectly happy to see Google Docs and others die off if it meant we moved back to real, locally run applications.

To the walled garden app stores? On most platforms web is the only uncensored way to deliver apps.
Right -- like the famous zinger about democracy, Google Docs is the worst implementation of collaborative word processing except for all the others that have been tried.
I would rather not have Google Docs than have all the other crap that comes along with allowing every website to do stuff that Google Docs "needs".
Seems like exactly the kind of thing permissions are for.
That is indeed how things like copy/paste through the menus already work; you install an extension to get the clipboard permission or the browser limits you to keyboard shortcuts
>WHY javascript code is even allowed to see all these actions of the user? We already loaded the page and rendered it - we users must already be free to do with the content as we please

Because on the modern web, the user is the content, sold to the highest bidder.

Javascript was a mistake.
Desktop envy: so you could create certain desktop-like interactions.