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