18 points

Building “applications” out of HTML documents – a single one or otherwise – is the sort of thing that belongs in one of those “stop doing X” memes, unironically.

permalink
report
reply
4 points

Why? I like that the Webplatform gives more Freedom to the Users.

permalink
report
parent
reply
3 points
*

No. Users should be forced to install hundreds of apps, with two thirds of apps running simultaneously. And if they don’t have memory left on the device for that, they should uninstall apps and reinstall them when necessary.

/s

permalink
report
parent
reply
70 points

These things are true if you build a SPA wrong. Believe it or not there are lots of ways to build server side rendered pages wrong too.

permalink
report
reply
8 points

Yeah this meme and the OP have no idea how to build an SPA.

permalink
report
parent
reply
29 points

I don’t know what the hell you’re interpreting into this 15-word-meme, but I do. I’m not saying all SPAs are shit, I’m saying far too many are. And “far too many” being more than one that I can think of. Even the Lemmy webpage breaks history caching.

permalink
report
parent
reply
2 points

I know what an SPA is, but I would be laughing so hard at this thread if I didn’t know what it meant.

“Yeah man. Dude doesn’t know his SPAs!”

Reminds me of that Saturday Night Live skit with the woodworkers comparing everything to working on the lathe.

permalink
report
parent
reply
-4 points

> implying there’s a “right way” to build an SPA.

permalink
report
parent
reply
13 points

There are a lot of standard practices like… using a router to load the content of your SPA according to the url.

permalink
report
parent
reply
-1 points
*

What I’m saying is, there’s no right way to build a thing that is inherently wrong.

permalink
report
parent
reply
4 points

There’s no one right way. Saying there are wrong ways doesn’t imply the existence of one right way, though.

permalink
report
parent
reply
7 points

Skill issue

permalink
report
reply
15 points

HTMX is great and is the only frontend development tool I don’t absolutely loathe. It enables lightweight SPA development, and provides a very simple and efficient mechanism for doing HTML over the wire.

permalink
report
reply
3 points

Not sure I would call HTMX a SPA framework though? Like it all’s easy async content fetching for sure, but it’s usually done across a MPA?

permalink
report
parent
reply
-1 points

Where did I call it a framework?

permalink
report
parent
reply
0 points

Sure, wrong term. I think my point still stands though. A SPA is *generally *“rehydrated” DOM elements from JSON data pulled from an API though. Where as HTMX is more akin to classic AJAX style page dynamism.

permalink
report
parent
reply
-7 points
*

Unfortunately it also kicks Content Security Policy square in the nuts and shoots a giant hole right through your website security, so if anyone on my team brings up using it I inform them it’s an instant security fail if we so much as touch it.

It’s a cute idea but horribly implemented. If your website has any security requirements, do not use htmx

Edit: the fact so many people have no idea about this and are downvoting is sad. People need to learn how CSP headers work, and why inherently HTMX completely bypasses this as it currently is designed.

permalink
report
parent
reply
5 points

HTMX comes with a variety of CSP options, though…

permalink
report
parent
reply
-1 points

Doesn’t matter, the entire implementation principle of how HTMX works and what it does inherently bypasses CSP. There’s no getting around that.

You fundamentally are invoking logic via HTML attributes, which bypasses CSP

permalink
report
parent
reply
7 points

Can you elaborate on that? I haven’t used it, but just assume if you host it on your own domain you can have it play nicely with csp, there are docs in their site about it. Where did it fall short for your use case?

permalink
report
parent
reply
-1 points

CSP allows you to whitelist/blacklist arbitrary Javascript, and ideally you completely blacklist online js from being executed at all, such that only .js files of same domain can be invoked by your website.

This serves the role of locking down injection attacks, only your explicitly approved Javascript can be invoked.

HTMX enables invoking of logic via HTML attributes on HTML elements… which CSP can’t cover

Which means you re-open yourself to injection attacks via HTML. Attackers can inject an HTML element with HTMX attributes and no amount of CSP will stop HTMX from going “Okey doke!” And invoking whatever the attributes say to do.

This effectively shoots even a completely locked down CSP config square in the nuts, totally defeating the entire point of using it.

It’s a cute idea but what is needed is a way to pre-emptively treat HTMX as a template file that transpiles everything out so the ajax happens in a separate .js file

If we had that, then it’d be safe and secure, as the whole “htmx attributes on elements” thing would just be a templating syntax, but when transpiled it wouldn’t be supported anymore so attackers can no longer inject html as an attack vector

permalink
report
parent
reply
44 points

As an elder developer… yea, we could use react to render complex web pages that erode expected functionality.

Or, like, I’m happy to just go back to server-side rendering… it’s surprisingly cheap to build and dead fucking simple.

permalink
report
reply
-1 points

More Server side logic means more vulnerabilities on your end.

permalink
report
parent
reply
5 points

I’ve seen front ends that build queries that are blindly executed by the backend - I’ve seen GraphQL that allows the client to read arbitrary users’ passwords from the database - I’ve seen attack ships on fire off the shoulder of ori- whoops, wrong memory.

Anyways, you can create vulnerabilities anywhere using anything - imo more server side logic might mean more vulnerabilities on the server but it means less vulnerabilities overall.

permalink
report
parent
reply
1 point

Why does it mean less vulnerabilities overall?

permalink
report
parent
reply
2 points

I prefer just writing my html, js, css, as is, and then transpiling to pack it down, treeshake, hash, cache bust, CSP, etc etc.

The amount if headache, overhead, inversion of control, mess, and bloat involved in frameworks tends to make me spend way too much time on writing boilerplate.

template and slot exist now, and modern js can do most of the shit fancy libs used to.

There’s very little need for frameworks unless you meed a SUPER dynamic website that has tonnes of mutability.

The amount if times i see people load in like 3 frameworks and 10mb of bullshit and ten js files to make a fucking static form that doesn’t even do anything fancy is insane.

Just fucking write the like… 8 lines of normal code to populate the form, wtf? Why are we using routers at all, HTTP already exists and does that, why did we re-invent http?

Front-end devs need to spend less time installing npm packages to try and magically solve their issues and just learn how to actually write code, SMH.

permalink
report
parent
reply
31 points

Elder developer here too, correctly making my SPAs has made my work significantly more efficient and maintainable now that my back end is basically a rest api and my front end requires very little network interaction after the initial load, which has been made pretty minimal.

permalink
report
parent
reply
1 point

I too have been doing this for years and I whole hearty agree with this comment.

For large complex sites, I ain’t never going back.

Actually even for simple sites I’m not sure I’ll go back.

permalink
report
parent
reply
1 point

If I ever have to do this again, I’ll scream.

<a href=“<?php echo “/about-us”;?>”>

permalink
report
parent
reply
6 points

Elder developer too, you can easily render react server side and statically. Once you remove state, react simply becomes pure functions that output jsx nodes, it’s also dead fucking simple, but gives the the possibility to add hydration and state later if you need it.

permalink
report
parent
reply
3 points

This is actually excellent advice for performance - you can bake the initial page data in!

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 6.2K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments