News for hackers. Stuff that matters.
Re:Ask HN: Simplest stack to build web apps in 2021? by e67f70028a46fba on Monday November 22, 2021 @05:19PM (#29312222)
http://htmx.org + whatever backend you like best
Re:Ask HN: Simplest stack to build web apps in 2021? by mamcx on Monday November 22, 2021 @05:53PM (#29312583)
And pair with https://tailwindcss.com and you are golden.

Seriously, is super productive this way!

Re:Ask HN: Simplest stack to build web apps in 2021? by tfehring on Monday November 22, 2021 @09:50PM (#29314087)
This is really interesting. Assuming I'm willing to trust the author's claim that semantic class names are the reason CSS is hard to maintain, what's the advantage of `<img class="w-32 h-32">` over `<img style="width: 32px; height: 32px;">`?
Re:Ask HN: Simplest stack to build web apps in 2021? by code_biologist on Tuesday November 23, 2021 @01:37AM (#29315154)
I'm willing to trust the author's claim that semantic class names are the reason CSS is hard to maintain

Here's a great talk on why he asserts that: https://www.youtube.com/watch?v=J_7_mnFSLDg

Not sure I 100% agree, but I appreciate the fresh look at oil patters.

Re:Ask HN: Simplest stack to build web apps in 2021? by mamcx on Tuesday November 23, 2021 @09:53AM (#29318447)
Think is like the most "functional" way to do CSS, in contrast with the "OO" way (like bootstrap).

Each class is applied in pipeline.

And ONLY to that tag. This is key. This leads to know, exactly, what are the effects on each tag, making the UI design very readable.

Then, you can customize it, and have a way to generate a VERY small CSS as result (another big advantage!) because the naming is normalized.

In short: Is the "same" but with more structure, predictability and tooling applied.

The more you need to customize, and the more pain you to "reverse" a CSS made by others, the more this make sense.

Re:Ask HN: Simplest stack to build web apps in 2021? by tga on Tuesday November 23, 2021 @09:32AM (#29318214)
Normally you wouldn't use `w-32` but rather something like `w-8`, that translates to `width: 2rem;`. Same with colors, you would use `bg-red-400`, that happens to translate to `rgba(248, 113, 113)`.

Half of TailwindCSS is a _way_ of using styles, but the other half is almost a theme: a set of margins, paddings, text sizes, colours, etc. that work well together.

Re:Ask HN: Simplest stack to build web apps in 2021? by mhoad on Tuesday November 23, 2021 @03:05AM (#29315639)
I like to think of Tailwind as CSS without the C.

Everything is now all at the same global namespace and all of the issues that people run into with specificity go away in the process.

It’s not my personal choice on how to solve that problem I think shadowDOM via web components are a much nicer option personally but Tailwind has a lot of very enthusiastic fans who seem to enjoy it.

Re:Ask HN: Simplest stack to build web apps in 2021? by slater on Tuesday November 23, 2021 @12:14AM (#29314817)
Less typing, less bandwidth (ab)used.
Re:Ask HN: Simplest stack to build web apps in 2021? by tfehring on Tuesday November 23, 2021 @12:59AM (#29314999)
I'd think the former would typically (depending on how many times the class is re-used) use more bandwidth, if anything, since it still requires the framework to define the `w-32 h-32` class attributes elsewhere using the more verbose identifiers. Plus the overhead for an additional request if that class definition happens in an external style sheet.
Re:Ask HN: Simplest stack to build web apps in 2021? by gls2ro on Tuesday November 23, 2021 @12:13AM (#29314814)
Media Queries
Re:Ask HN: Simplest stack to build web apps in 2021? by ASalazarMX on Monday November 22, 2021 @05:42PM (#29312459)
Wait, this looks and feels like a very pragmatic way of making modern websites. How has this not become more popular? What are its cons?
Re:Ask HN: Simplest stack to build web apps in 2021? by mamcx on Monday November 22, 2021 @05:58PM (#29312619)
> What are its cons?

Is very pragmatic. That means your whole investment in the arcane ways of JS are dust. Not hipster at all.

---

More seriously, Is of little issues here. You setup and it works, so is not something that lead to "generate content" like other setups.

I found only a significant issue (to me) (https://github.com/bigskysoftware/htmx/issues/596) but then I do something that have never done in long time with a JS library: I poke into the source and fix it myself. Far easier than expected! (ie: The code is plain!)

Re:Ask HN: Simplest stack to build web apps in 2021? by boyter on Monday November 22, 2021 @06:10PM (#29312730)
You return HTML from your "api" endpoint's is the biggest opposition I have found. Can mean additional work when you do want to switch to JSON, as the endpoints end up not being very reusable.

I quite like HTMX myself, although I consider it a tool you use to enhance websites and not something you use to build full blown web apps.

Re:Ask HN: Simplest stack to build web apps in 2021? by deniz-a on Monday November 22, 2021 @06:29PM (#29312844)
You don't return HTML from API endpoints, you return it from your UI endpoints. You could reuse those for JSON with content negotiation, or have a frontend server+backend server setup where the backend server is also a public API, or some other solution.
Re:Ask HN: Simplest stack to build web apps in 2021? by boyter on Monday November 22, 2021 @06:35PM (#29312891)
Semantics over the name aside, you end up returning small chunks of HTML from newly defined routes that are only useful for your HTMX frontend, hence my usage of API as the interface really only makes sense to the machine and not the user without the rest of the page content.

Yes you could inspect the headers and such to determine what type to return, but the core problem remains, that the HTML in those is not reusable whereas as JSON would be.

How much overhead this is for you depends on your design of course, but it does mean some work might potentially be wasted if you go down the full SPA application later and even if not changing layouts and such might be a pain.

Re:Ask HN: Simplest stack to build web apps in 2021? by recursivedoubts on Monday November 22, 2021 @07:21PM (#29313219)
Re:Ask HN: Simplest stack to build web apps in 2021? by animesh on Tuesday November 23, 2021 @03:23AM (#29315730)
Thanks for HTMX and your essays. Today I was reading HTMX documentation on what to do when we design API-first for a particular project but don't want any of the frontend magic aka SPA. I found immediately that I need to use both json_enc and client-side-templates extensions. Hope I am on the right path.
Re:Ask HN: Simplest stack to build web apps in 2021? by recursivedoubts on Tuesday November 23, 2021 @08:27AM (#29317507)
hi animesh, that would only be the case if you are trying to retrofit htmx on top of an existing JSON API

if it is greenfield development, it is much better to simply return SSR HTML and avoid that complexity

you can join the discord for more immediate help:

https://htmx.org/discord

Re:Ask HN: Simplest stack to build web apps in 2021? by animesh on Tuesday November 23, 2021 @10:42AM (#29319102)
That makes sense. I didn't think about it that way, but traditional MVC views would do just as well I guess for greenfield work.
Re:Ask HN: Simplest stack to build web apps in 2021? by ASalazarMX on Monday November 22, 2021 @08:49PM (#29313755)
> Semantics over the name aside, you end up returning small chunks of HTML from newly defined routes that are only useful for your HTMX frontend, hence my usage of API as the interface really only makes sense to the machine and not the user without the rest of the page content.

Web2py (being phased out by py4web which I haven't tried) made that very easy. If your api is accessed as api/hello.html, it can return HTML. According to the extension, hello.json, hello.csv, hello.txt, hello.pdf, etc. can return the adequate content.

Of course you can always return JSON regardless of the extension, but I found the same endpoints serving different formats very convenient.

Re:Ask HN: Simplest stack to build web apps in 2021? by midrus on Tuesday November 23, 2021 @01:37PM (#29321419)
I'm a big fan of Unpoly. Pretty similar to Htmx. Unpoly just fits my brain better.

https://unpoly.com/