3 ms·
I've become a fan of https://htmx.org https://htmx.org for this reason. A small 10KB lib that augments HTML with the essential good stuff (like dynamic imports
by matchagaucho 1y ago
I've become a fan of https://htmx.org https://htmx.org for this reason.
A small 10KB lib that augments HTML with the essential good stuff (like dynamic imports of static HTML)
- HumanOstrich 1y agoSeems like overkill to bring in a framework just for inlining some static html. If that's all you're doing, a self-replacing script tag is neat: <script> function includeHTML(url) { const s = document.currentScript fetch(url).then(r => r.text()).then(h => { s.insertAdjacentHTML('beforebegin', h) s.remove() }) } </script> ... <script> includeHTML('/footer.html') </script> The `script` element is replaced with the html from `/footer.html`.
- librasteve 1y agothis here is the main idea of HTMX - extended to work for any tag p, div, content, aside … there are many examples of HTMX (since it is a self contained and tiny) being used alongside existing frameworks of course for some of us, since HTMX brings dynamic UX to back end frameworks, it is a way of life https://harcstack.org https://harcstack.org (warning - raku code may hurt your eyes)
- rapnie 1y agoIf you want it more straight-forward and simple hypermedia approach, then check out https://data-star.dev https://data-star.dev (highly recommended, there are great youtube video's where the maintainers discuss their insights). Following up where htmx took things.
- johnisgood 1y agoBut this requires JavaScript...
- PaulHoule 1y ago... but the folks behind that standard don't want to encourage browsing with Javascript off.
- HumanOstrich 1y agoWhy would the ES standards organization that defines JavaScript syntax encourage people not to use it?
- lelanthran 1y ago> But this requires JavaScript... Depending on the specific objection to Javascript, this may or may not matter: 1. You object to any/all JS on a page? Yeah, then this won't work for you. 2. You object to having to write JS just to get client-side includes? This should mostly work for you. It all depends on what the actual objection is.
- gforce_de 1y agoThe minified version needs ~51 kilobytes (16 compressed): $ curl --location --silent "https://unpkg.com/htmx.org@2.0.4" | wc -c 50917 $ curl --location --silent "https://unpkg.com/htmx.org@2.0.4" | gzip --best --stdout | wc -c 16314
- recursivedoubts 1y agosee fixi if you want bare-bones version of the same idea: https://github.com/bigskysoftware/fixi https://github.com/bigskysoftware/fixi