From 5bc71beafdb6e4aed64b2341f4b384f04dd912b8 Mon Sep 17 00:00:00 2001 From: Ron Date: Fri, 4 Feb 2022 18:54:42 +0100 Subject: [PATCH] Added webpack installation to docs (#775) Co-authored-by: Ronny Vedrilla --- www/docs.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/www/docs.md b/www/docs.md index 32b417d6..da0fb306 100644 --- a/www/docs.md +++ b/www/docs.md @@ -114,6 +114,35 @@ For added security, you can load the script using [Subresource Integrity (SRI)]( If you are migrating to htmx from intercooler.js, please see the [migration guide here](/migration-guide). +### webpack + +If you are using webpack, you have to do the following steps: + +1. Install `htmx` via your favourite package manager (like npm or yarn) +2. Add the import to your `index.js` + +``` js + import 'htmx.org'; +``` + +If you want to use the global `htmx` variable (recommended), you have to inject it to the window scope. + +3. Create a custom JS file +4. Import this file to your `index.js` (below the import from step 2) + +``` js + import 'path/to/my_custom.js'; +``` + +5. Add the following line + +``` js + window.htmx = require('htmx.org'); +``` + +6. Rebuild your bundle + + ## [AJAX](#ajax) The core of htmx is a set of attributes that allow you to issue AJAX requests directly from HTML: