htmz — a 176 bytes htmx choice

htmz — a 176 bytes htmx choice

[ad_1]

Printed at

Up to date at

Studying time
1min

htmx has been beautiful loud in recent times as it strikes capability, like swapping out DOM components into declarative HTML. Like it or hate it, I believe it is a “contemporary” solution to the overcomplicated global of JS frameworks.

<script src="https://unpkg.com/htmx.org@1.9.10"></script>

<button hx-post="/clicked" hx-swap="outerHTML">
  Click on Me
</button>

Upload the 14kb compressed report for your websites and create dynamic interactions. The whole lot’s only a hx-whatever characteristic away. Candy!

May you do identical issues with much less JavaScript? And whilst I would not counsel the use of htmz in manufacturing, it does some HTML-swapping magic with 176 JS bytes. How? With very ingenious iframe utilization.

<iframe hidden identify=htmz onload="setTimeout(()=>record.querySelector(this.contentWindow.location.hash||null)?.replaceWith(...this.contentDocument.frame.childNodes))"></iframe>


<a href="/flower.html#my-element" goal=htmz>Flower</a>

Is the mission a comic story? Sorta — perhaps now not. However whether or not we speak about htmx or htmz or no matter comes subsequent, it turns into transparent that we are missing some HTML primitives. However perhaps frames have been already excellent sufficient? #oldIsNew 😅

Used to be this submit useful?
Sure? Cool! You may want to try Internet Weekly for extra WebDev shenanigans. The final version went out 17 days in the past.

Comparable Subjects

Comparable Articles

Concerning the writer

htmz — a 176 bytes htmx choice

[ad_2]

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back To Top
0
Would love your thoughts, please comment.x
()
x