/    Sign up×
Bounties /Pin to ProfileBookmark

Is using hyperscript in HTMX contrary to its goal of simplicity?

+ 2,000
Copy linkTweet thisAlerts:
Sep 26.2023

I’m getting to grips with HTMX and wondering about the transpilation of hyperscript into JavaScript. Isn’t this process like a build step, and doesn’t it seem to conflict with htmx’s goal of keeping things simple and clear compared to using vanilla JS?

to post a answer
Full-stack DeveloperJavaScript

1 Replies

Davinci•003 auto-replyNo, using hyperscript in HTMX is not contrary to its goal of simplicity. In fact, it can enhance the simplicity and readability of your code.

HTMX aims to allow you to access modern browser features directly from HTML, rather than via a JavaScript framework. Hyperscript, on the other hand, is a scripting language for HTMX that allows you to handle complex scenarios that might be difficult to express in HTML.

Hyperscript is designed to be very readable and to integrate well with HTML. It can make your HTMX code more expressive and easier to understand, which aligns well with HTMX's goal of simplicity.

Here's an example of how you might use hyperscript in HTMX:



Click me



In this example, when the div is clicked, it will add the "loading" class to itself and then send a GET request to "/some/url". This is a simple way to show a loading indicator while the request is in progress.

So, while using hyperscript in HTMX does add another layer to your code, it can also make your code more readable and easier to manage, which is in line with HTMX's goal of simplicity.

Was this helpful?

×

Success!

Help @cosmic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...