Fireship · @fireship
htmx in 100 seconds
Uploaded July 7, 2023 · Length 2:27
Summary
htmx explained as a UI library for web development that simplifies HTML and replaces JavaScript frameworks.
- htmx
- ui library
- web development
- html
- javascript framework
- hypermedia
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
htmx a UI library for the web that can
- 0:03
replace your JavaScript framework with
- 0:05
the Simplicity of HTML playing HTML is
- 0:07
more capable than you think every time
- 0:09
you click on a link or submit a form it
- 0:11
automatically sends an HTTP request to
- 0:13
the server and renders the response in
- 0:15
the UI it's so easy but why stop there
- 0:17
HDMX Embraces an architectural
- 0:19
constraint known as Hyper media as the
- 0:21
engine of application state by adding
- 0:23
new attributes to HTML that can handle
- 0:25
the complex requirements of modern uis
- 0:27
it gives you the ability to make a
- 0:29
request to the server from any element
- 0:31
by providing an attribute with an HTTP
- 0:33
verb and the URL endpoint on the server
- 0:35
it'll take the response from the server
- 0:37
and replace this element asynchronously
- 0:39
or it can specify a Target to replace a
- 0:41
different element on the page it can
- 0:43
also customize the event on which it's
- 0:44
triggered along with modifiers like
- 0:46
delay and throttle to control the way
- 0:48
the request is sent it keeps track of
- 0:49
the loading state so you can show a
- 0:51
spinner apply CSS transitions for
- 0:53
animation and builds on the HTML
- 0:55
validation API to validate forms it even
- 0:57
has a client-side router called boost
- 0:59
that can make any traditional web
- 1:01
application feel like a faster single
- 1:03
page application and it also includes
- 1:04
extensions for more advanced features
- 1:06
like websockets and Integrations with
- 1:08
other HTML Frameworks like Alpine to
- 1:11
install it simply Import htmx in a
- 1:13
script tag from the head of an HTML
- 1:15
document you just put the hyper back
- 1:16
into hypertext now all you need is a
- 1:18
server in your favorite programming
- 1:20
language that returns html text as a
- 1:22
response now we can use the HX get
- 1:24
attribute to make a request to this
- 1:26
endpoint along with HX swap to replace
- 1:28
this element with the HTML on the
- 1:30
response when swapping though we don't
- 1:32
only have the option to replace the
- 1:34
outer HTML but we could also append or
- 1:36
prepend the response to the existing UI
- 1:38
or the HX Target attribute allows us to
- 1:40
move the UI to a completely different
- 1:42
element it finds that element with a CSS
- 1:44
selector but has additional syntax like
- 1:47
next and closest allowing you to easily
- 1:49
find the proper element without a bunch
- 1:51
of custom IDs we might also use HDMX
- 1:53
indicator to show a loading spinner and
- 1:55
write a CSS transition animation for the
- 1:58
incoming element behind the scenes a


