The case against htmx

Mark Jivko
9 Mar 202406:20

Summary

TLDRThis video discusses the rise in popularity of HTMX, a framework allowing Ajax requests without JavaScript by using server responses in pure HTML. While HTMX is easy to learn, it breaks the separation of concerns, leading to poor user experience and scalability issues. The speaker argues that despite HTMX's simplicity, it results in increased bandwidth requirements and complex handling of server responses. The recommendation is to invest in learning modern frameworks like React, which, although initially challenging, offer better long-term developer and user experiences.

Takeaways

  • 📈 HDMX is gaining popularity for sending Ajax requests without writing JavaScript.
  • 💡 HDMX allows server responses to be pure HTML, which is then injected into the page.
  • ⚠️ The speaker believes HDMX is problematic and should be avoided for anything other than hobby projects.
  • 🛠️ Pros of HDMX: It’s easy to learn and requires minimal HTML and no JavaScript knowledge.
  • 🚫 Cons of HDMX: It breaks the separation of concerns, mixing HTML, CSS, and JavaScript in server responses.
  • 🔄 Non-trivial tasks with HDMX require extensive parsing and stripping of unwanted elements, leading to a messy process.
  • ⏳ HDMX can degrade user experience as users wait for entire HTML responses, including unnecessary elements.
  • 💸 Using HDMX can be more expensive due to larger bandwidth requirements and poorer user experience.
  • 🔧 Modern frameworks like React offer better long-term developer experience and maintain separation of concerns.
  • 📉 The user experience with HDMX worsens over time as the project grows, leading to scalability issues and high bandwidth consumption.

Q & A

  • What is HDMX and what does it allow users to do?

    -HDMX is a minimalistic framework that enables users to send Ajax requests without writing JavaScript. It requires the server response to be pure HTML, which is then injected into the page.

  • What are the main advantages of using HDMX?

    -The main advantages of HDMX are its ease of learning and the minimal knowledge required of HTML and JavaScript.

  • Why does the speaker compare using HDMX to jumping into a pool filled with sharks?

    -The comparison is used to emphasize the potential risks and downsides of using HDMX, warning that it could lead to significant problems down the line.

  • How does HDMX break the separation of concerns in web development?

    -HDMX breaks the separation of concerns by sending HTML wrapped data from the server instead of pure data. This HTML includes styling, images, and JavaScript event listeners, which should ideally be separate from the data.

  • What issues arise when using HDMX for non-trivial server responses?

    -Non-trivial server responses require parsing and cleaning the HTML to extract pure text, which involves removing CSS, images, table elements, canvas, video, audio, and inline styling, among other things.

  • How does HDMX impact user experience?

    -HDMX can destroy user experience by requiring users to wait for the entire HTML response to load from the server each time an action is performed, instead of a faster, stateless call.

  • What are the common issues with HDMX related to user interaction?

    -Common issues include double clicking, triple clicking, and event bubbling, which are not well handled by HDMX and can lead to a poor user experience.

  • Why is HDMX considered more expensive to run than a simple open API?

    -HDMX is more expensive because it requires sending and processing large chunks of HTML over HTTP for every request, which consumes more bandwidth and server resources.

  • How does mixing HTML and backend logic affect the application?

    -Mixing HTML and backend logic leads to a less maintainable and harder-to-reason application, as it intertwines styling, layout, and interactivity with data in API responses.

  • Why is it important to not sacrifice user experience for developer experience?

    -User experience should not be sacrificed because the end user is the customer who pays for the product or service, and a poor user experience can lead to dissatisfaction and loss of customers.

  • What does the speaker recommend for long-term development instead of using HDMX?

    -The speaker recommends learning JavaScript or TypeScript and using modern text-based frameworks like React for a better developer experience and improved user experience in the long term.

  • What is the speaker's stance on the importance of separation of concerns, bandwidth, and user experience?

    -The speaker emphasizes that separation of concerns, bandwidth efficiency, and user experience are crucial and should not be compromised, regardless of the framework or technology used in web development.

Outlines

00:00

🚫 The Pitfalls of HDMX: Separation of Concerns and UX Issues

The speaker discusses the growing popularity of HDMX, a lightweight framework that enables Ajax requests without JavaScript, but warns of its potential pitfalls. HDMX requires server responses to be in pure HTML, which is then injected into the page. While it's easy to learn with minimal HTML knowledge, the speaker argues that HDMX breaks the separation of concerns by mixing data with HTML, CSS, and JavaScript. This leads to issues with parsing server responses, handling internationalization and localization, and managing edge cases like event bubbling. The speaker emphasizes the negative impact on user experience due to the need to load entire HTML pages for each interaction, rather than just data. HDMX is criticized for its lack of scalability, poor performance, and high bandwidth usage, making it unsuitable for modern web applications. The speaker concludes by advocating for the importance of maintaining a clear separation of concerns and prioritizing user experience over developer convenience.

05:03

📚 Learning Modern Technologies Over HDMX for Long-Term Success

Continuing the discussion on HDMX, the speaker highlights the limitations of using this framework as projects grow in complexity. They point out that despite efforts to optimize HDMX, the lack of separation of concerns, poor scalability, and negative user experience persist. HDMX is described as an outdated tool that, despite its initial simplicity, fails to meet the demands of modern web development. The speaker encourages developers to invest time in learning JavaScript or TypeScript and to work with modern frameworks like React. This approach, while it may have a steeper initial learning curve, leads to a significantly better developer experience and, most importantly, a superior user experience in the long run. The speaker concludes by stressing the importance of prioritizing user experience and the value of mastering current technologies over relying on outdated methods.

Mindmap

Keywords

💡HDMX

HDMX is a lightweight framework that enables the sending of Ajax requests without the need for JavaScript. It is characterized by its simplicity and the requirement for server responses to be in pure HTML format, which is then injected into the page. In the video, the speaker expresses concerns about the use of HDMX, likening it to a 'stone age tool' due to its potential negative impact on user experience and separation of concerns.

💡Ajax requests

Ajax, which stands for Asynchronous JavaScript and XML, is a set of web development techniques that allows web pages to communicate with servers without requiring a full page refresh. In the context of the video, HDMX facilitates Ajax requests, but the speaker argues against this approach due to the drawbacks it presents.

💡Separation of concerns

Separation of concerns is a design principle for organizing code by separating it into distinct sections, each addressing a separate concern. The video emphasizes that HDMX breaks this principle by mixing HTML, styling, and data within server responses, which can complicate parsing and lead to a poor user experience.

💡User experience (UX)

User experience refers to how a person feels when interacting with a system, which includes the practical, emotional, and meaningful aspects of the person's use. The video argues that HDMX negatively impacts UX due to issues like long loading times for HTML responses and the need for extensive parsing to extract useful data.

💡Developer experience (DevX)

Developer experience is the measure of how easily and efficiently developers can build and maintain applications. The video contrasts DevX with UX, suggesting that while HDMX may offer a quick start for developers, it sacrifices long-term UX, which is more critical for the success of a web application.

💡Bandwidth

Bandwidth refers to the maximum rate of data transfer across a given path. The video points out that HDMX can lead to increased bandwidth usage due to the transmission of large HTML responses, which is not only inefficient but also detrimental to user experience.

💡Progressive web applications (PWA)

Progressive web applications are web applications that load like regular web pages but can offer user experiences like native apps. The video suggests that HDMX is incompatible with the principles of PWA due to its requirement for complete HTML responses, which hinders the ability to create efficient, app-like web experiences.

💡Modern web frameworks

Modern web frameworks are advanced tools and libraries that help developers build robust and scalable web applications. The video advocates for the use of such frameworks, like React, over HDMX, as they offer better developer experience and user experience in the long term, despite a steeper initial learning curve.

💡JavaScript

JavaScript is a high-level, interpreted programming language that is widely used in developing interactive web pages. The video discusses the need for developers to learn JavaScript or TypeScript to effectively use modern web frameworks, which is a skill that becomes increasingly valuable as one progresses in web development.

💡TypeScript

TypeScript is a superset of JavaScript that adds static type definitions to the language. It is often used in modern web development to improve code quality and maintainability. The video encourages developers to learn TypeScript as part of mastering modern web development practices.

💡HTML

HTML, or HyperText Markup Language, is the standard markup language for creating web pages and web applications. The video criticizes HDMX for its reliance on pure HTML server responses, which can include unnecessary elements and styling, leading to a bloated and less efficient user experience.

Highlights

HDMX is a lightweight framework that allows sending Ajax requests without JavaScript.

Server responses with HDMX must be pure HTML, which is then injected into the page.

HDMX is easy to learn, requiring minimal HTML knowledge and no JavaScript.

Breaking the separation of concerns is a significant downside of using HDMX.

HDMX can lead to a poor user experience due to the need to load entire HTML responses.

HDMX responses include unnecessary elements like styling, images, and event listeners.

Parsing server responses in HDMX requires removing HTML elements and styling to get to the text.

HDMX can complicate internationalization and localization due to its approach to HTML responses.

HDMX is less efficient than a simple open API, leading to increased bandwidth usage and costs.

HDMX is not suitable for progressive web applications due to its requirement for complete HTML responses.

Mixing HTML for styling and layout with data and interactivity in API responses can lead to difficulties in reasoning about the app.

Developer experience should never be prioritized over user experience, especially in the long term.

Modern text-based frameworks like React offer a better developer experience and maintain high user experience standards.

Learning a modern framework like React has a higher initial learning curve but pays off with a better developer experience and user experience.

HDMX can lead to scalability issues and poor user experience as a project grows.

The separation of concerns, bandwidth efficiency, and user experience are crucial factors in choosing a web development framework.

HDMX is considered outdated, and modern web development should utilize contemporary tools and practices.

The speaker recommends learning JavaScript or TypeScript and going through React documentation for long-term benefits.

Transcripts

play00:00

so this thing's been growing in

play00:03

popularity lately and I feel we need to

play00:05

talk about it it's called HDMX and it's

play00:08

a tiny tiny framework if you could call

play00:10

it a framework that allows you to send

play00:13

Ajax requests without writing JavaScript

play00:16

the server response has to be pure HTML

play00:20

which is then injected into the page now

play00:23

why am I talking about this like I feel

play00:26

like I'm watching someone about to jump

play00:28

in a pool filled with sharks and I need

play00:30

to warn them stop what you're doing is

play00:32

wrong you're going to get yourself

play00:33

eternal life now let's start with the

play00:36

pros of HDMX it's really easy to learn

play00:40

you barely need to know any HTML at all

play00:43

and no

play00:44

JavaScript um and basically that's it

play00:48

that's the entire list of Pros I could

play00:49

think of now let's go over the list of

play00:51

cons and why you should avoid using htx

play00:54

for anything other than hobby projects

play00:58

it breaks down separation of concerns so

play01:01

instead of receiving pure data from your

play01:03

server you're getting it wrapped in HTML

play01:06

that HTML also has various area labels

play01:10

and extra JavaScript event listeners

play01:12

like on click onload Etc that HTML also

play01:16

has styling HTML 5 elements like video

play01:19

and audio and a canvas and some SVG and

play01:22

some images and some table elements etc

play01:25

etc so what's wrong with breaking

play01:27

separation of concerns you might ask

play01:30

well if you want to do anything

play01:32

non-trivial with your server response

play01:34

you first need to parse it with

play01:36

JavaScript so you're out of HTM X

play01:39

instantly you first need to remove the

play01:41

CSS remove the extra images remove the

play01:44

extra table elements remove the extra

play01:46

canvas video audio and image elements

play01:49

remove the inline styling remove the

play01:51

event listeners remove anything and

play01:54

everything except the text and what

play01:55

you're left with is just pure text you

play01:57

still need to parse that into an object

play01:59

good luck with internationalization and

play02:02

localization issues it's going to be a

play02:05

horrible horrible mess to do anything

play02:08

above the simple HTML replacement thing

play02:11

that HDMX does for you secondly it

play02:14

destroys your user experience so every

play02:16

time someone clicks on a button they now

play02:19

have to wait for the entire HTML

play02:21

response to be loaded from the server

play02:24

not just you know status call and

play02:26

through no it has to be this huge HTML

play02:29

with sty in and images and all that

play02:32

stuff and it's all sent over HTTP what

play02:34

about edge cases in fact these are very

play02:37

common issues like double clicking

play02:38

triple clicking event bubbling and so on

play02:41

well the short answer is bad luck it's

play02:43

much more expensive to run than a simple

play02:46

open API for example so look the user

play02:49

interface is for user interface things

play02:52

and the back end is for backend things

play02:54

if you're mixing the two you're going to

play02:56

get bad side effects and one of them is

play02:59

having to shuttle huge chunks of HTML

play03:02

back and forth you cannot cash those

play03:04

responses either because they have to be

play03:07

complete HTML by Design that's what HTM

play03:11

X requires of you so you can forget

play03:13

about Progressive web applications it's

play03:15

as if that entire web stack doesn't

play03:17

exist anymore so what's the difference

play03:19

between a 20 bytes response and a 20

play03:22

kilobytes response with every single

play03:24

click dollar dollar bills that's that's

play03:27

the difference apart from the extra

play03:30

bandwidth requirements and poorer user

play03:32

experience you're going to find it

play03:34

extremely difficult to reason with an

play03:36

app that mixes styling layout which is

play03:39

HTML data and interactivity in its API

play03:43

responses this is all just a discussion

play03:45

around developer experience versus user

play03:48

experience at at the end of the day devx

play03:51

versus ux I would argue that most modern

play03:55

text TXS are verbos they do have a

play03:58

little bit of a learning curve so so you

play04:00

need to know your JavaScript your

play04:01

typescript and you need to go through a

play04:03

few tutorials to get started but that's

play04:05

fine because once you do and you learn

play04:07

to use available tooling your developer

play04:09

experience dramatically improves the

play04:13

point though is not to sacrifice user

play04:16

experience ever even if available

play04:18

tooling was indeed really really

play04:21

difficult to learn you would still need

play04:23

to never ever sacrifice ux over devx

play04:27

because your end user is your customer

play04:30

and they pay for the whole thing you

play04:32

should really never sacrifice ux

play04:35

especially for short live early days

play04:37

developer experience when you're just

play04:39

starting out yes it's much faster to

play04:41

start an HDMX project than a react

play04:44

project but medium to long term your

play04:46

developer experience as a react

play04:48

developer or any other modern text de is

play04:51

orders of magnitude better than using no

play04:54

framework at all or Worse HDMX the user

play04:58

experience on the other hand never

play04:59

recovers with HDMX this is a fact the ux

play05:02

actually gets worse in time with HDMX as

play05:05

your project grows look you'll find out

play05:08

the hard way that no matter how much

play05:10

time you spend on the thing considering

play05:12

all edge cases and trying to optimize it

play05:15

you're always going to bump into the

play05:17

lack of separation of concerns problem

play05:19

poor scalability and really really bad

play05:22

horrible user experience with

play05:24

unjustifiable bandwidth requirements

play05:26

HDMX is a stone age tool it's seducted

play05:29

in its Simplicity but we're building

play05:32

modern web applications on Modern

play05:34

Hardware using modern text TXS that

play05:37

become exponentially more lovable as you

play05:40

climb that learning curve trust me we

play05:42

don't need to get back to the 1980

play05:44

something unless it's the Goldbergs and

play05:47

we don't need yet another member berries

play05:50

pie just do yourself a favor learn

play05:52

JavaScript or typescript go through that

play05:55

react documentation and thank yourself

play05:57

in 6 months so this is it this is my

play05:59

entire rant for today separation of

play06:01

concerns matters bandwidth matters and

play06:04

user experience trumps developer

play06:07

experience no matter what framework or

play06:09

text Tech you're using so if you want to

play06:12

keep on enjoying uh rants like this one

play06:16

don't forget to hit that subscribe

play06:17

button and I'll see you in the next one

play06:19

bye-bye

Rate This

5.0 / 5 (0 votes)

関連タグ
HDMX FrameworkAjax RequestsUser ExperienceDeveloper EfficiencyWeb DevelopmentSeparation of ConcernsModern Web AppsBandwidth UsageJavaScriptReactPerformance Issues
英語で要約が必要ですか?