Problem/Motivation
As part of #3404409: [Plan] Gradually replace Drupal's AJAX system with HTMX and ongoing discussion in Drupal Slack copied below, there is strong support for adding the HTMX library to core as a first step towards building a functionally equivalent system to Drupal's jQuery based Ajax API.
Summary from Slack
[nod_] The scope of the existing issue shouldn't change, we can open a child issue that deals with adding the library...in that issue we'll need to do the dependency evaluation
[catch] Yeah everything @nod_ says is correct
Proposed resolution
- Complete the dependency evaluation
- Add the HTMX library to core.
Dependency Evalution
- Maintainership of the package
-
HTMX is an open source project with about 100 maintainers. The lead maintainer is Carson Gross who also has created an account here on drupal.org specifically to support this effort.
- Security policies of the package
-
The HTMX project published a security policy to support our use of the library.
- Expected release and support cycles
- Releases are expected quarterly.
- Code quality
- The source code is well maintained and includes automated tests.
- Other dependencies it would add, if any (the full tree, not just direct dependencies), and evaluations for those dependencies as well
- HTMX has no dependencies by design.
- License
- The license for HTMX is BSD Zero Clause License, which is listed as a GNU compatible license. It is a public domain equivalent license. The license provides all four freedoms without restriction.
Remaining tasks
- ✅ MR to add the library and update vendor-update.js script
- ✅ Framework manager sign-off
- ✅ Release manager sign-off
- Update Current JavaScript dependencies page
- Write release notes
Release notes snippet
In order to start replacing our custom ajax framework the htmx library was added to Drupal.
Issue fork drupal-3520723
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:
- 3520723-add-htmx-dependency
changes, plain diff MR !11928
Comments
Comment #2
fathershawnComment #3
fathershawnComment #4
fathershawnComment #5
fathershawnComment #6
fathershawnComment #7
fathershawnComment #8
catchComment #11
nod_few comments on the MR
Comment #12
fathershawnComment #13
fathershawnMR is updated. Leaving as "active" until we have the security policy resolved
Comment #14
nod_Code is good to go for me, we can RTBC once the security issue is managed. To be more accurate the status should be postponed since we're waiting on external third party for a reply :)
Comment #15
fathershawnComment #16
fathershawnComment #17
fathershawnComment #19
nod_Crediting htmx maintainer for resolving the security policy issue
Comment #20
nicxvan commentedI confirmed the security policy was there as well.
I tried to follow the instructions to report a security issue, but the report a security vulnerability button was not there, I pinged @1cg on slack about it and he enabled the security reporting.
We should document this bit for future dependency evaluations so that it's easier to onboard projects.
It seems for github anyway there are two steps. Here is the documentation page on github: https://docs.github.com/en/code-security/security-advisories/working-wit...
After he configured it I confirmed that the button is now available and the security instructions are complete!
Comment #21
quietone commentedformatting change in the issue summary.
Comment #22
quietone commentedAlso need release manager sign-off, which I don't see here.
Comment #23
catchI very reluctantly worked on the jQuery 4 port of jquery.form.js because it was one of the last blockers to releasing Drupal 11. While the AJAX system works, it has a lot of custom and long-unmaintained JavaScript behind it and is one of our heaviest jQuery dependencies. There has been no progress in modernising any of that js in the past 10-15 years.
The plan to introduce HTMX alongside the AJAX system as a new API means we can ensure feature parity and improve APIs, but without having to try to implement complex JavaScript or BC layers - instead running both side by side until we can fully deprecate and remove the AJAX system.
Comment #24
catchI very reluctantly worked on the jQuery 4 port of jquery.form.js because it was one of the last blockers to releasing Drupal 11. While the AJAX system works, it has a lot of custom and long-unmaintained JavaScript behind it and is one of our heaviest jQuery dependencies. There has been no progress in modernising any of that js in the past 10-15 years, instead we're left with a custom fork of an unmaintained GitHub repo.
The plan to introduce HTMX alongside the AJAX system as a new API means we can ensure feature parity and improve APIs, but without having to try to implement complex JavaScript or BC layers - instead running both side by side until we can fully deprecate and remove the AJAX system.
So from a release management point of view this will eventually be a large net reduction in our JavaScript dependencies and while there are details to figure out the transition plan is good.
I think this needs FEFM rather than FM review so switching the tags over.
Comment #25
nod_+1 for this, validated that in #3404409-99: [Plan] Gradually replace Drupal's AJAX system with HTMX
Comment #26
nod_Comment #27
nod_Comment #28
fathershawnComment #29
fathershawnComment #30
pdureau commentedComment #31
fathershawnWe have test failures that seem unrelated to this work: https://git.drupalcode.org/issue/drupal-3520723/-/pipelines/481254
Comment #32
fathershawnTests passed 🎉
Comment #33
pdureau commentedIndeed, it is green now ✅ following @nod_ https://git.drupalcode.org/project/drupal/-/merge_requests/11928/diffs?c...
I will take care of this today.
Comment #34
mstrelan commentedDoes this need a change record?
Comment #35
fathershawnI would recommend that not this child issue, but #3521173: Process attachments (CSS/JS) for HTMX responses and add drupal asset libraries carry the change record. My reason is that although this adds the library, without the ability to bring in dependent CSS/JS it's not really usable yet. HTMX natively has properties to merge header tags but that clearly misses a lot of our JS.
If someone with more familiarity about the expectations around change records thinks that 2nd issue would be better place, I'll move the tag.
Comment #36
nicxvan commentedI would think both issues would get one.
Even if it's not strictly usable in this release it is a new dependency people should be notified that it will be installed.
Though I note #3352389: Add open-telemetry/sdk and open-telemetry/exporter-otlp as dev dependencies didn't have one.
I would think a simple one that said htmx is now a core dependency starting with htmx version xyz and a link to the github would suffice.
Comment #37
nod_We didn't have a change notice to say a library was added (like sortable and such), only the issue when it's actually used has a change notice.
For now we don't want people to use it as-is, we need to integrate it to make sure things like security and performance are taken into account.
Comment #38
catchYeah agreed with #37, we can add the CR when it's more meaningful, but retrospectively add this issue to it then for context.
Comment #39
fathershawnComment #41
pdureau commentedCommitted 216a91c and pushed to 11.x. Thanks!
Comment #42
pdureau commentedComment #43
fathershawnSomeone with more permissions must be needed to edit the JS Dependencies page. I don't know if someone edited source or there are other text filters available, but I can't add additional headers and rows to the existing table.
Here's the needed data:
Repository https://github.com/bigskysoftware/htmx
Release cycle Releases are expected quarterly.
Security policies https://github.com/bigskysoftware/htmx/security
Security issue reporting https://github.com/bigskysoftware/htmx/security/advisories/new
Contact(s) 1cg, fathershawn
Comment #44
quietone commentedAssigning to myself to sort out the documentation.
Comment #45
quietone commentedI made an entry for HTMX at Current JavaScript dependencies and completed it from the information in the issue summary. Update that entry as needed.
Comment #46
longwaveLocally when I run
yarn vendor-updateon 11.x I get some changes without changing anything in package.json or the lockfile:assets/vendor/htmx.orgis created, which is a copy ofassets/vendor/htmxhtmx.debugis upgraded from 2.0.1 to 2.0.4Comment #47
nod_let's remove the debug extension, it's not used yet and there is a built-in way of doing the same thing (
htmx.logAll())as for the folder that's my bad, I removed the "folder" key and we needed it
Comment #48
nod_Comment #49
quietone commentedUsing the latest changes there are still no changes to the package file or the lock file.
This also still needs a release note.
Comment #50
nod_The lock file is correct, latest version is 2.0.4: https://www.npmjs.com/package/htmx.org?activeTab=versions
The debug extension is in the package because of how they used to do things: https://github.com/bigskysoftware/htmx/blob/master/dist/ext/README.md
Comment #51
longwave@nod_ I think we also need to delete
assets/vendor/htmx/debug.jsfrom the repo?After applying the patch:
Maybe
vendor-updateshould delete the target directory first, to handle deleted files?Comment #52
nod_that's a good idea, follow-up though
Comment #54
longwaveCommitted 042eb55 and pushed to 11.x. Thanks!
Comment #56
andypostmaybe change record could be added here? that's very helpful
Comment #57
mstrelan commented@andypost see #34-39
Comment #59
fathershawnComment #60
fathershawn