htmx-ext-no-load

1.0.1 • Public • Published

No load HTMX Extension

Will automatically stop HTMX making a request if the current page URL equals the request URL.

Usage

Script tag

HTMX recommends you link from unpkg:

<head>
    ...
    <script src="https://unpkg.com/htmx-ext-no-load@^1/no-load.js" defer></script>
    ...
</head>

NPM package

If you are using Vite as a package manager.

npm install @rollup/plugin-inject htmx-ext-no-load
// vite.config.js
import inject from '@rollup/plugin-inject'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    inject({
       htmx: 'htmx.org'
    }),
  ],
})
// app.js
import htmx from 'htmx.org'
import 'htmx-ext-no-load'

Any time a user tries to load data that would be from the current browser path it will be intercepted and not loaded.

If you want to check individual targets (that aren't page URLs) then you can add to trigger elements:

<body>
    <button hx-get="/your-endpoint" hx-ext="no-load">Click me</button>
</body>

Package Sidebar

Install

npm i htmx-ext-no-load

Weekly Downloads

8

Version

1.0.1

License

ISC

Unpacked Size

2.49 kB

Total Files

3

Last publish

Collaborators

  • craigharman