</> htmx
high power tools for HTMLintroduction
htmx gives you access to fetch(), CSS & View Transitions, SSE and more directly in HTML, using attributes, so you can build interactive interfaces with the simplicity and power of HTML.
htmx is small (~10k min.br’d), dependency-free, extendable & has reduced code base sizes by up to 67% when compared with react
motivation
- Why should only
<a>&<form>be able to make HTTP requests? - Why should only
click&submitevents trigger them? - Why should only
GET&POSTmethods be available? - Why should you only be able to replace the entire screen?
By removing these constraints, htmx completes HTML as a hypertext
quick start
<script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0-alpha5/dist/htmx.min.js"></script>
<!-- have a button POST a click via AJAX -->
<button hx-post="/clicked" hx-swap="outerHTML">
Click Me
</button>
The hx-post and hx-swap attributes on this button tell htmx:
When a user clicks on this button, issue an AJAX request to /clicked, and replace the entire button with the HTML response
htmx is the successor to intercooler.js
Read the docs introduction for a more in-depth… introduction.
Thank you to all our generous sponsors, including:
ʕ •ᴥ•ʔ made in montana