Live data from Hacker News

UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

unsuckjs.com

181–190 of 194 posts

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#181

Earlier quoted context omitted.

It sucks so much its unreal, forces OOP JS, which causes extreme amounts of boiler plate code and mutation bugs, making a simple change becomes a one week task. I'm just doing a complete rewrite of a legacy codebase made with TS, webcomponents and lit into a modern framework, which is about the only sane thing to do with it.

I would love to see a more fleshed out rebuttal of it. Is it a scale issue?

it's the frontend equivalent of bad microservices

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#182
post #157
post #97

Earlier quoted context omitted.

Irony is that javascript handlers on elements were frowned upon in 90s/00s because of separate of concerns that HTML should be HTML and JS should attach it's events in a separate file. Now all of these libraries have an onclick that mirrors those original JS event handlers in the same html with no separation!

If implemented incorrectly, these onclick handlers are a security hazard, because they prevent you from using a strict content security policy. https://www.w3.org/TR/CSP2/#directives

I'll never understand CSP not allowing onclick handlers. Having all your javascript in a separate file makes it very hard to diagnose and understand what is causing the event on the element.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#183
post #65

Earlier quoted context omitted.

> Having a build step also increases activation energy and friction Yes this! As an interpreted language it should not need a build step. Every project should be git clone https://github.com/user/foo && cd foo && google-chrome index.html

I'm also against building and compiling (I work with Python and Ruby on the backend) but there were good reasons to have those steps, at least in the past and probably still now. Short and very incomplete list, feel free to reply and add points: * slow network, especially on mobile * reduce the size of the download by minifying * reduce the number of calls by bundling files in a single one * Inconsistent JS and HTML…

Most of those points could be taken care of by building only when deploying though, skipping the phase during development. I think most of the annoyance with a build step comes from how you can’t do anything unless the tooling for it is set up, as well as how it gunks up the tweak → reload cycle.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#184

Earlier quoted context omitted.

Why not?

It sucks so much its unreal, forces OOP JS, which causes extreme amounts of boiler plate code and mutation bugs, making a simple change becomes a one week task. I'm just doing a complete rewrite of a legacy codebase made with TS, webcomponents and lit into a modern framework, which is about the only sane thing to do with it.

What's a mutation bug?

In react, mutating a model is a bug. It's left up to the developer to remember not to do that. Outside of react, mutating a model seems like a natural fit for the way stuff actually works and it's not considered a bug.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#185

Earlier quoted context omitted.

But wouldn’t you be happier if each and every component on the page paid the price of a full templating system? No? Oh yeah, I forgot that Web Components are a terrible idea that are only marginally successful because they can claim to be a “standard” when they’re not any more standard than any other JavaScript.

I honestly don't know how WCs got through the standards process successfully, they're so bad.

The answer is that they're from ~2013: before React etc. taught us how to make SPAs. It was an early attempt, so it sucks. JS is best when it "paves the cowpath" and takes something we could already do slowly in browser and gives us a better native API for same thing, like querySelector or IntersectionObserver or how there was no built in way to parse a query string before URLSearchParams. Anytime JS goes first, the API is crap, like the DOM Node APIs themselves.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#186

Earlier quoted context omitted.

But wouldn’t you be happier if each and every component on the page paid the price of a full templating system? No? Oh yeah, I forgot that Web Components are a terrible idea that are only marginally successful because they can claim to be a “standard” when they’re not any more standard than any other JavaScript.

You only "pay" for as many template systems as you use, not one for every component, and modern template systems are far smaller than the major frameworks.

Each independent script you import is another load blocker. You could have scripts A and B both import template C, but then you're slowing things down even more, and no "HTTP2 push!" is not the answer.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#187

Earlier quoted context omitted.

Yes! I don't think Mithril gets enough attention. It's my go to JS framework when I need more than Vanilla JS but don't need something like React.

Did you ever run into performance problem with Mithril? I like how simple it is to use but the idea to run / diff the entire component tree on every user interaction kinda scares me

See benchmarks: https://krausest.github.io/js-framework-benchmark/2023/table...

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#188
post #157

Earlier quoted context omitted.

If implemented incorrectly, these onclick handlers are a security hazard, because they prevent you from using a strict content security policy. https://www.w3.org/TR/CSP2/#directives

I'll never understand CSP not allowing onclick handlers. Having all your javascript in a separate file makes it very hard to diagnose and understand what is causing the event on the element.

onclick and other in-HTML handlers have some unsafe eval-like behavior for old compatibility reasons (with ES1 and the old web/old DOM) and I feel like the CSP designers were overly-cautious of XSS exploits via DOM manipulation that are hard to do in practice, but still in theory a major security concern.

I wonder if there were a better way to opt-in to "use strict" (and maybe even ESM friendliness) in onclick handlers if that would have fewer CSP concerns. I doubt there are any current proposals to build such tools for HTML, though.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#190

It would be handy to see the license. It's becoming increasingly more dangerous to use anything in the GPL family for anything but the narrowest of use cases. It's to the point that, even now, if it's GPL I refuse to incorporate it, even in personal projects. And I'm not against open source... Everything I write is MIT.

MIT is against open source. Only copyleft is truly open
Post reply on HN