Problem/Motivation

Looking to use the preload extension— are there any tips or best practices for adding HTMX extensions in Drupal? Should i make a module, even if only a libraries.yml file, so others just find it and don't have to think about it?

Steps to reproduce

Proposed resolution

Submodule in this module.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork htmx-3553907

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

  • 1.5.x Comparecompare
  • 3553907-add-preload-extension Comparecompare

Comments

mlncn created an issue. See original summary.

mlncn’s picture

Status: Active » Needs review

This is working— definitely needs documentation, and i was wondering if it is feasible to place hx-ext="preload" into the body tag, since it is annoying to have to add that to something outside of / before the data-hx-get="…" preload tag/line.

Would be great to have a little feedback now, including if the documentation should go in a help topic.

mlncn’s picture

Like it would be great to somehow use https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Htmx%21Ht... to add to the <body> tag whenever the htmx_preload/preload library is loaded on the page.

fathershawn’s picture

Thanks for pushing me to open 1.6.x! We have things to remove that have been added in 11.3 to core.

Let's add a folder for extensions in docs. I'll move the debugging extension page there as well.

I think you are on the right track in #3. I'm doing that manually here: https://git.drupalcode.org/project/htmx/-/blob/1.5.x/modules/htmx_debug/... but now we have the Htmx object.

fathershawn’s picture

Version: 1.5.x-dev » 1.6.x-dev
fathershawn’s picture

Version: 1.6.x-dev » 2.x-dev
fathershawn’s picture

Status: Needs review » Needs work

We will also need a README with sha values like we have for debug and you will want to add a hook_preprocess_html to add the attribute to body as is done in htmx_debug.