Live data from Hacker News

UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

unsuckjs.com

131–140 of 194 posts

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#131

Earlier quoted context omitted.

The beauty of htmx is that it doesn't matter what you use on the backend. Literally anything that'll render HTML will suffice. Even static HTML files on a web server will do. No need for an application server at all if you're clever and your needs are simple.

What if I want the website to work even when JavaScript is not turned on? I'd need a backend server and some frontend logic handling that case.

Not necessarily. It depends on what you need. For example suppose you were implementing an news reader with two panes. Left pane is a list of titles and previews, right pane is a full article for the selected item in the left pane.

You can make the left pane a list of links to dedicated pages, and then add an htmx attribute to indicate that when the user has JavaScript to instead fetch a html snippet with just full article and swap it into the right pane.

If you had a reasonably bounded set of articles you could statically generate all the /article/id.html and the /article/id/snippet.html files, though a backend probably makes sense.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#132

Earlier quoted context omitted.

The beauty of htmx is that it doesn't matter what you use on the backend. Literally anything that'll render HTML will suffice. Even static HTML files on a web server will do. No need for an application server at all if you're clever and your needs are simple.

What if I want the website to work even when JavaScript is not turned on? I'd need a backend server and some frontend logic handling that case.

In that case you need to have everything rendered server side and perhaps get creative with the usage of forms firing off events that can be intercepted by the server and then return a new page.

Certain things like Nav menu drop downs and folding text can’t be done with native CSS and HTML.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#133

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.

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

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#134
Sort of unrelated but I find it ironic this website is written in Python. It's a single HTML page. Make it a static site and host it for free/low-cost on S3 or something.

Why do you need to host this website on a server, use Docker, etc?

My personal blog is a static site using Next.js, I pay $0 to host it on S3.

To me this is less about simplicity and more about being anti JS ecosystem, and being different just to be different.

Any legacy site probably has some kind of Javascript framework, jQuery, or something set up where adding another library on this list adds complexity. Any new site that requires a decent amount of interactivity would probably be better with a battle tested framework like React. I've tried many of the libraries listed here, have tried the view engine + Alpine approach, etc, and time and time again I find it's simpler from a development perspective to just use Next.js.

That is to say, for any hobby project, use whatever you want. Try new things. But for production apps, just use React.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#135

Earlier quoted context omitted.

IIRC, it's not about private use but about distribution. We publish libraries under MIT, since other corporate users would very likely need to distribute those. But the higher-level Apps we publish under GPL, so that downstream is obligated to keep it open-source (but there is no obligation to submit a PR upstream). And there are more than a few companies that use our GPL stuff, internally and don't redistrubute and…

Yes, distribution is the key. Suppose that my company has powerful video editing software that we sell (which is distribution). Consider that it has unique functionality and has taken a decade to develop by a team of developers, all of whom have salaries, insurance, retirement, etc. that need to be paid, otherwise the software would not exist. Proprietary code and profit are more than appropriate in this situation, a…

It's really weird that you describe requiring reciprocation as poisoning downstream. Proprietary software also doesn't allow you to just incorporate their code in your proprietary software and distribute it. Nobody described plain jane closed source software as "infectious" even though by any reasonable definition it is vastly more so. Open source software will let you remediate the situation by removing it or open sourcing it without penalty while closed source software if incorporated without following the license will see the owners lawyers crunching your bones to suck out the marrow. If GPL is a cold then proprietary software is ebola.

In the overwhelming number of cases the party is selling something other than their software and you are equally free to negotiate a different license with the developer if you have different needs.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#136

Earlier quoted context omitted.

What if I want the website to work even when JavaScript is not turned on? I'd need a backend server and some frontend logic handling that case.

In that case you need to have everything rendered server side and perhaps get creative with the usage of forms firing off events that can be intercepted by the server and then return a new page. Certain things like Nav menu drop downs and folding text can’t be done with native CSS and HTML.

Hold my beer: that’s something you can do with the input checkbox trick.

Here’s an example: https://codepen.io/daviddarnes/pen/abVaGG

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#137

This is a brilliant list, I'm a particular fan of HTMX and Alpine.js. The move back towards small dependancy free JS libs, in combination with modern JS ES Modules, is absolutely brilliant. I learnt web dev back in the late 90s by doing "view source", and was still learning about new things that way well over a decade later. If we can move back towards that, by not having a build step, it will be amazing for new devs…

> I learnt web dev back in the late 90s by doing "view source", and was still learning about new things that way well over a decade later. If we can move back towards that, by not having a build step, it will be amazing for new devs starting out and learning new things. Same here, and I couldn't agree more. Had minified library soup with dynamic page content been the norm back then it would've been much harder to get…

Unfortunately we need the JS still because the standards are so lacking, and when they’re not it takes a while to get everybody on it.

As a general example, despite three decades of the web existing across the world in many jurisdictions with more than one language, the solution to translation for a site is just some translation framework or tediously maintaining a whole copy of your site per language.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#138

Earlier quoted context omitted.

> I learnt web dev back in the late 90s by doing "view source", and was still learning about new things that way well over a decade later. If we can move back towards that, by not having a build step, it will be amazing for new devs starting out and learning new things. Same here, and I couldn't agree more. Had minified library soup with dynamic page content been the norm back then it would've been much harder to get…

Unfortunately we need the JS still because the standards are so lacking, and when they’re not it takes a while to get everybody on it. As a general example, despite three decades of the web existing across the world in many jurisdictions with more than one language, the solution to translation for a site is just some translation framework or tediously maintaining a whole copy of your site per language.

The standards are fine. The problem is that the front end web is the DOM. I love the DOM, but it scares the shit out of people. Most people would rather cut their hand off or sell their children into child slavery than walk the DOM with 3 instructions. Its super weird and gets more weird when those people are actually confronted with this irrational behavior.

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#139
post #134

Sort of unrelated but I find it ironic this website is written in Python. It's a single HTML page. Make it a static site and host it for free/low-cost on S3 or something. Why do you need to host this website on a server, use Docker, etc? My personal blog is a static site using Next.js, I pay $0 to host it on S3. To me this is less about simplicity and more about being anti JS ecosystem, and being different just to be…

>I find it ironic this website is written in Python. It's a single HTML page. Make it a static site and host it for free/low-cost on S3 or something. Why do you need to host this website on a server, use Docker, etc?

Originally it _was_ just HTML + CSS, but I wanted each library's repository metadata (latest version, last commit, etc) to be dynamically retrieved and doing that client-side was brittle and way too slow. So, I used it as an excuse to see how far I could push my own personal static-site framework (https://coltrane.readthedocs.io/en/latest/).

Re: UnsuckJS: Progressively enhance HTML with lightweight JavaScript libraries

#140

Nice to see sprae on there it's handy when you want reactivity with minimal fuss. I would lobby for featuring Webreflection's uhtml it is a workhorse for me personally.

Agree! Webreflection is a huge reference when it comes to using Javascript to its fullest, reducing dependencies and using the platform™
Post reply on HN