Lurker News

Comments (242) 68 threads

Earlier comments
nymanjon1 reply#
This is fantastic. Right now in my PWA I'm using a little library I created called `html-form` (HTMF) and I need to implement it as a SPA to avoid service worker fetching on every page change. So, I used a similar attribute to `hx-select`. But it adds quite a bit of code to the code base. Using your pattern I can remove all that added code and I can stop using hash navigation. Nice and simple.

Thank you for putting your code out in the public so I can learn from it!

nymanjon#
Playing with the code it doesn't fit my use case. It seems like it would be really cool if you have a very narrow use case and that use case doesn't grow. Having your browser parse any scripts you have twice doesn't make much sense. Also, working with eventing would be an interesting problem to solve. I guess you would need to add an element for that, maybe something like `{"my-event": "my event data"}`.

So, it seems like this pattern could probably take you quite a ways. But the main issue I have is that you would need to parse all that JS out twice by the browser. But if you don't have the need for any `script` tags in what you pass back it would be pretty nice.
Also, it wouldn't work for graceful degradation as the server wouldn't know if you need the whole page or a segment. As HTMX adds a header that lets you know that JavaScript is being used by the front end.
Overall, I think it is really cool and it would be neat to see how far you could take this.

h43z#
Why the "||:not(*)" in the iframe onload handler of htmz and not just "null"?
h43z1 reply#
Here a version that works for cross origin requests.


but website you are requesting has to embed the below script tag.

  just some other text


You would still set the DOM destination on the main page.

  dog
chatmasta#
Careful with that snippet, targetOrigin of * is dangerous. I could embed your iframed content on my own site and then you'd happily send me the entire HTML inside the iframe.
yellowapple#
One downside of this approach is that it fills my browser history with a bunch of extra entries, which ain't ideal (especially for my Back button). I'd guess that's probably fixable as an htmz "extension"?

That aside, I love the concept.

Load more comments