https://htmx.org logo
Yep, the problem is interesting. I think we could...
# htmx-general
m
Yep, the problem is interesting. I think we could do a "merge" where we compare the old and new content, probably w/ a dumb O(n^2) algorithm, merge in the new styles and scripts, remove the old ones
b
Curious where the
^2
comes from. Compare two lists and add and subtract I see as simple
O(n)
. Is there a possibility of a nested structure within the head that I'm missing? For example current head:
Copy code
<src 1>
<src 2>
Incoming head:
Copy code
<src 2>
<src 3>
Steps: 1. Make a Set A of each entry's outerHTML in current head 2. Make a Set B of each entry's outerHTML in incoming head 3. For each key in A which does not exist in B, remove it from the current head 4. For each key in B which does not exist in A, add it to the current head
m
Yeah, you are right, I wasn't thinking, it's O(n+m)