| 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 | ## 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/extensions/ws/) and [Server Sent Events](https://htmx.org/extensions/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 ([~12k min.gz'd](https://cdn.jsdelivr.net/npm/htmx.org/dist/)), |
| 19 | [dependency-free](https://github.com/bigskysoftware/htmx/blob/master/package.json) & |
| 20 | [extendable](https://htmx.org/extensions) |
| 21 | |
| 22 | ## motivation |
| 23 | |
| 24 | * Why should only `<a>` and `<form>` be able to make HTTP requests? |
| 25 | * Why should only `click` & `submit` events trigger them? |
| 26 | * Why should only GET & POST be available? |
| 27 | * Why should you only be able to replace the *entire* screen? |
| 28 | |
| 29 | By removing these arbitrary constraints htmx completes HTML as a |
| 30 | [hypertext](https://en.wikipedia.org/wiki/Hypertext) |
| 31 | |
| 32 | ## quick start |
| 33 | |
| 34 | ```html |
| 35 | <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.min.js" |
| 36 | integrity="sha384-Oy2c9csBEA+9v16GUyopnXJLPb4gkvyTURnEnThDuxz8iQHiSwNAZduw0dMGmB/b" |
| 37 | crossorigin="anonymous"></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 | Want to contribute? Check out our [contribution guidelines](dev/CONTRIBUTING.md) |
| 67 | |
| 68 | No time? Then [become a sponsor](https://github.com/sponsors/bigskysoftware#sponsors) |
| 69 | |
| 70 | ### hacking guide |
| 71 | |
| 72 | To develop htmx locally, you will need to install the development dependencies. |
| 73 | |
| 74 | Run: |
| 75 | |
| 76 | ``` |
| 77 | npm install |
| 78 | ``` |
| 79 | |
| 80 | Then run the test suite: |
| 81 | |
| 82 | ``` |
| 83 | npm test |
| 84 | ``` |
| 85 | |
| 86 | At this point you can modify `/src/htmx.js` to add features, and then add tests in the appropriate area under `/test/tests`. |
| 87 | |
| 88 | * `/test/tests/unit` - unit tests for individual functions |
| 89 | * `/test/tests/attributes` - attribute specific tests |
| 90 | * `/test/tests/end2end` - end-to-end tests |
| 91 | * `/test/tests/ext` - extension tests |
| 92 | * `/test/manual` - manual tests that cannot be automated |
| 93 | |
| 94 | htmx uses [@web/test-runner](https://modern-web.dev/docs/test-runner/overview/) with [Playwright](https://playwright.dev/) |
| 95 | and the [chai](https://www.chaijs.com/) assertion framework. |
| 96 | |
| 97 | ## haiku |
| 98 | |
| 99 | *javascript fatigue:<br/> |
| 100 | longing for a hypertext<br/> |
| 101 | already in hand* |