liveBook · Manning

HTMX

As explained in Web Component Development with Modern Libraries and Tooling

A JavaScript library that enables HTML attributes to issue requests and update page content without writing conventional client-side application code.

HTMX lets HTML attributes trigger requests and place returned HTML into the page, reducing the need for conventional client-side application code. section 11.2

Load server-rendered greetings

A button can request /hello-world?name=SSR and insert the response into #greetings: <button hx-get="/hello-world?name=SSR" hx-target="#greetings" type="button">hello-world SSR</button>. The server returns HTML containing rendered custom elements, which HTMX places in the target. section 11.2

Listing 11.4 public/index.html
<!doctype html>
<html lang="en">
  <head>
    <title>Vanilla Web Component SSR</title>
    <script src="https://unpkg.com/htmx.org@2.0.8"></script>
  </head>
  <body>
    <button
      hx-get="/hello-world?name=SSR"
      hx-target="#greetings"
      type="button"
    >
      hello-world SSR
    </button>
    <div id="greetings"></div>
  </body>
</html>

Inspect the complete page markup, including the HTMX 2.0.8 script, request attributes, and target element. section 11.2

How Web Component Development with Modern Libraries and Tooling covers it

How deep it goes
Demonstrates GET requests and target selection through two attributes, without surveying broader HTMX APIs or client-side internals.
Examples
Uses a hello-world button that requests a named greeting and populates a greetings div with server-rendered custom elements.
What it assumes
Assumes basic HTML markup and a server endpoint capable of returning HTML.
What you can do after
Apply it via HTMX by adding hx-get and hx-target attributes to request and replace page content.
How it connects
Connects HTML attributes with HTTP requests, server-side rendering, custom elements, and returned HTML.

Also explained in

Compare how 3 books explain HTMX →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Component Development with Modern Libraries and Tooling. The section links point to the parts of the book it draws on.