htmz

Dev tools

html fragment loader

SHOW HN2024

1,020points
242comments
#7of 3,515 in 2024
Top 1%of 2024 by points

How HN took it

MixedNo clear lean

33 positive, 56 neutral or asking, 6 mixed, 21 critical, out of 116 comments about the project. Thread score +0.10.

Idea: 18 for, 4 againstExecution: 4 for, 5 againstDesign: 4 for, 5 againstPerformance: 2 for, 5 againstDocs: 2 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Clever, elegant use of existing browser features

    From 4 comments
    • This is a glorious demonstration of someone really understanding the platform. I don't expect I would ever use it, but I think it's excellent.
      azornathogron on HN
    • I cannot believe how simple and elegant this is. Using an iframe as a request/response proxy to enable targeted replacement is just
      fractaledmind on HN
    • Jesus Christ, this is all at once simple, powerful and useful. So little code, achieving so much!!!
      lelanthran on HN
    • Simple and powerful, as the vanilla web should be. Thank you for this (small) gem :)
      sodimel on HN
  • Simple and small code

    From 2 comments
    • Kind of impressive that the installation script was that small.
      Alifatisk on HN
    • Jesus Christ, this is all at once simple, powerful and useful. So little code, achieving so much!!!
      lelanthran on HN

Objections

  • Breaks back button and browser history

    From 3 comments
    • Apparently it breaks your back button too.
      internet2000 on HN
    • 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…
      yellowapple on HN
    • It's quite good. I noticed that my back button had to be repeatedly pressed to go back to write this comment, after interacting with the examples a few times. I'm sure that's…
      jallasprit on HN
  • Breaks without JavaScript, no graceful degradation

    From 2 comments
    • Given that this uses `target`, doesn't it mean that unlike htmx you can't easily make this gracefully degrade when JS isn't enabled? And, yes, I know, saying "when JS isn't…
      Arch-TK on HN
    • Zero noscript fallback. Please don't use this.
      account42 on HN
  • Likely conflicts with Content-Security-Policy

    From 1 comment
    • This seems likely to have issues with most "Content-Security-Policy" rules because of the inline script in "onload" and the iframe. Makes it a non starter in real world…
      sublinear on HN
  • Uses slot and URL fragments incorrectly

    From 2 comments
    • Reusing the <slot> element like this is a bad idea - it has very specific behavior in browsers. In a shadow root it'll be replaced by the children of the host element, no matter…
      spankalee on HN
    • Except using a URL fragment refers to a “resource that is subordinate to another, primary resource” not a destination. They point out the URL abuse, so why do it? Slot is also a…
      andrewmcwatters on HN

Requests

  • Support for cross-origin requests

    From 1 comment
    • Here a version that works for cross origin requests. ``` <iframe hidden name=xhtmz onload="onmessage=x=>document.querySelector(x.data.target).innerHTML=x.data.content"></iframe>…
      h43z on HN
  • Preprocessor or no-JS support

    From 1 comment
    • Oh, if this snippet is just a search and replacer... would it be possible for this to be a preprocessor as well? Would allow for noJS websites.
      mofosyne on HN

Questions

  • How does it compare to htmx

    From 1 comment
  • Can returned JavaScript run

    From 1 comment
    • Can it trigger JS returned from the proxy? Something like <script>alert(123);</script>
      tommica on HN

Alternatives named

  • htmx

    From 2 comments
    • That's a great hack and it shows how close the browser is to offering SPA natively. Just a few attributes and we could avoid the iframe. It's probably more useful to prove a…
      tambourine_man on HN
    • I happened to spend a little more time on htmx this weekend which htmz was inspired by. htmx/htmz does do well for simple use cases, htmx does well for SSR heavy cases(e.g.…
      synergy20 on HN
  • pjax

    From 1 comment
    • Reminds me of pjax [1], except pjax works over XHR instead of an iframe and uses pushState by default to keep the back button working. [1]: https://github.com/defunkt/jquery-pjax
      jdp on HN
  • Hotwire

    From 1 comment
    • This is very similar to how Hotwire does replacing of HTML generated on server side in Ruby on Rails.
      agp2572 on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/39429370)