
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
htmx-remove
Advanced tools
:toc: macro :toclevels: 5 :figure-caption!:
:htmx_link: link:https://htmx.org[htmx]
= htmx Remove
This library is an {htmx_link} link:https://htmx.org/extensions[extension] that can be optionally used for situations in which you need to remove an element from the DOM that was originally added by {htmx_link} without making an HTTP request.
This library extension is most useful in situations in which you have clicked a link or triggered an htmx HTTP request which inserts a new DOM element such as form which has a cancel link/button. In these situations, you don't need to make an HTTP request to cancel/remove the newly added form. Instead, you only need to remove the original form.
toc::[]
== Features
== Screencasts
== Requirements
. {htmx_link}. . link:https://nodejs.org[Node] (optional, for development). . link:https://www.ruby-lang.org[Ruby] (optional, for development).
== Setup
The following assumes you are already using {htmx_link} and have it configured in the same manner as documented in this setup section.
To use via the HTML script element, add the following to your layout:
To use via Import Maps, add the following to your layout:
To install via link:https://www.npmjs.com[NPM], run:
Once the library is installed, you only need to import it:
== Usage
A typical use case is to have a link which triggers an {htmx_link} request for adding a new form element to the DOM. Example:
Upon clicking the New link, the following element would be added to the DOM after {htmx_link} resolves the request:
Cancel
----In this case, clicking the Cancel button would remove the entire form element from the DOM. This is made possible by first adding the hx-ext="remove" attribute to the form element and then adding the data-remove="true" attribute to the button element.
Behind the scenes, this extension will listen for click events for the first element with a data-remove="true" attribute. Once clicked, the corresponding element for which this extension is loaded and associated with (i.e. form) via the hx-ext="remove" attribute will be removed from the DOM.
That's it! A simple extension for dealing with DOM elements a user might want to cancel/remove because they decided adding something new wasn't necessary after all.
== Development
To contribute, run:
To build, run:
To view interactive demonstration, run
bin/demo
== Tests
To test, run:
== Deployment
To deploy, follow these steps:
. Ensure link:https://alchemists.io/projects/milestoner[Milestoner] is installed.
. Ensure you are on the main branch.
. Run the following:
== link:https://alchemists.io/policies/license[License]
== link:https://alchemists.io/policies/security[Security]
== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]
== link:https://alchemists.io/policies/contributions[Contributions]
== link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin]
== link:https://alchemists.io/projects/htmx-remove/versions[Versions]
== link:https://alchemists.io/community[Community]
== Credits
FAQs
A htmx extension for DOM element removal via click events.
The npm package htmx-remove receives a total of 89 weekly downloads. As such, htmx-remove popularity was classified as not popular.
We found that htmx-remove demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.