htmx
htmx copied to clipboard
`htmx.process` queries the whole document, not only the supplied element, causing slowdowns
When supplying HTML from external sources, we call htmx.process
on them to let htmx initialise any handlers/do necessary work. However, since support for hx-on
, it queries over the whole document (not the supplied element) to find these attributes. This can be very slow in situations where many nodes are to be processed in a short period of time, in a page with many elements.
https://github.com/bigskysoftware/htmx/blob/2fe2f67555c9d3941c5041e1b3846f69996eb4a4/src/htmx.js#L1901-L1922
Ah, I see elt is supplied as a parameter to document.evaluate. Regardless, it still does not perform well enough
There does seem to be a discrepancy between the situation where you have document.evaluate
available and where you don't. The fallback code above does not only look at elt
and its children, but the entire document. That doesn't seem to be correct...
Related to #2019
Ah, I see elt is supplied as a parameter to document.evaluate. Regardless, it still does not perform well enough
There does seem to be a discrepancy between the situation where you have
document.evaluate
available and where you don't. The fallback code above does not only look atelt
and its children, but the entire document. That doesn't seem to be correct...
Due to the way document.evaluate
is called, the entire document is scanned, not only elt
and its children, even though elt
is supplied as a parameter. I think there should have been a .
before the //*
. See #2019 for more information.
I think this is a duplicate of #2019, which is now closed, so I'm closing this as fixed