1 | [![</> htmx](https://raw.githubusercontent.com/bigskysoftware/htmx/master/www/static/img/htmx_logo.1.png "high power tools for HTML")](https://htmx.org)
|
2 |
|
3 | *high power tools for HTML*
|
4 |
|
5 | [![Discord](https://img.shields.io/discord/725789699527933952)](https://htmx.org/discord)
|
6 | [![Netlify](https://img.shields.io/netlify/dba3fc85-d9c9-476a-a35a-e52a632cef78)](https://app.netlify.com/sites/htmx/deploys)
|
7 | [![Bundlephobia](https://badgen.net/bundlephobia/dependency-count/htmx.org)](https://bundlephobia.com/result?p=htmx.org)
|
8 | [![Bundlephobia](https://badgen.net/bundlephobia/minzip/htmx.org)](https://bundlephobia.com/result?p=htmx.org)
|
9 |
|
10 | ## introduction
|
11 |
|
12 | htmx allows you to access [AJAX](https://htmx.org/docs#ajax), [CSS Transitions](https://htmx.org/docs#css_transitions),
|
13 | [WebSockets](https://htmx.org/docs#websockets) and [Server Sent Events](https://htmx.org/docs#sse)
|
14 | directly in HTML, using [attributes](https://htmx.org/reference#attributes), so you can build
|
15 | [modern user interfaces](https://htmx.org/examples) with the [simplicity](https://en.wikipedia.org/wiki/HATEOAS) and
|
16 | [power](https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm) of hypertext
|
17 |
|
18 | htmx is small ([~14k min.gz'd](https://unpkg.com/htmx.org/dist/)),
|
19 | [dependency-free](https://github.com/bigskysoftware/htmx/blob/master/package.json),
|
20 | [extendable](https://htmx.org/extensions) &
|
21 | IE11 compatible
|
22 |
|
23 | ## motivation
|
24 |
|
25 | * Why should only `<a>` and `<form>` be able to make HTTP requests?
|
26 | * Why should only `click` & `submit` events trigger them?
|
27 | * Why should only GET & POST be available?
|
28 | * Why should you only be able to replace the *entire* screen?
|
29 |
|
30 | By removing these arbitrary constraints htmx completes HTML as a
|
31 | [hypertext](https://en.wikipedia.org/wiki/Hypertext)
|
32 |
|
33 | ## quick start
|
34 |
|
35 | ```html
|
36 | <script src="https://unpkg.com/htmx.org@1.9.12"></script>
|
37 | <!-- have a button POST a click via AJAX -->
|
38 | <button hx-post="/clicked" hx-swap="outerHTML">
|
39 | Click Me
|
40 | </button>
|
41 | ```
|
42 |
|
43 | The [`hx-post`](https://htmx.org/attributes/hx-post) and [`hx-swap`](https://htmx.org/attributes/hx-swap) attributes tell htmx:
|
44 |
|
45 | > "When a user clicks on this button, issue an AJAX request to /clicked, and replace the entire button with the response"
|
46 |
|
47 | htmx is the successor to [intercooler.js](http://intercoolerjs.org)
|
48 |
|
49 | ### installing as a node package
|
50 |
|
51 | To install using npm:
|
52 |
|
53 | ```
|
54 | npm install htmx.org --save
|
55 | ```
|
56 |
|
57 | Note there is an old broken package called `htmx`. This is `htmx.org`.
|
58 |
|
59 | ## website & docs
|
60 |
|
61 | * <https://htmx.org>
|
62 | * <https://htmx.org/docs>
|
63 |
|
64 | ## contributing
|
65 | Want to contribute? Check out our [contribution guidelines](CONTRIBUTING.md)
|
66 |
|
67 | No time? Then [become a sponsor](https://github.com/sponsors/bigskysoftware#sponsors)
|
68 |
|
69 | ### hacking guide
|
70 |
|
71 | To develop htmx locally, you will need to install the development dependencies.
|
72 |
|
73 | __Requires Node 15.__
|
74 |
|
75 | Run:
|
76 |
|
77 | ```
|
78 | npm install
|
79 | ```
|
80 |
|
81 | Then, run a web server in the root.
|
82 |
|
83 | This is easiest with:
|
84 |
|
85 | ```
|
86 | npx serve
|
87 | ```
|
88 |
|
89 | You can then run the test suite by navigating to:
|
90 |
|
91 | <http://0.0.0.0:3000/test/>
|
92 |
|
93 | At this point you can modify `/src/htmx.js` to add features, and then add tests in the appropriate area under `/test`.
|
94 |
|
95 | * `/test/index.html` - the root test page from which all other tests are included
|
96 | * `/test/attributes` - attribute specific tests
|
97 | * `/test/core` - core functionality tests
|
98 | * `/test/core/regressions.js` - regression tests
|
99 | * `/test/ext` - extension tests
|
100 | * `/test/manual` - manual tests that cannot be automated
|
101 |
|
102 | htmx uses the [mocha](https://mochajs.org/) testing framework, the [chai](https://www.chaijs.com/) assertion framework
|
103 | and [sinon](https://sinonjs.org/releases/v9/fake-xhr-and-server/) to mock out AJAX requests. They are all OK.
|
104 |
|
105 | You can also run live tests and demo of the WebSockets and Server-Side Events extensions with `npm run ws-tests`
|
106 |
|
107 | ## haiku
|
108 |
|
109 | *javascript fatigue:<br/>
|
110 | longing for a hypertext<br/>
|
111 | already in hand*
|