https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • e

    echoing-book-71490

    12/09/2022, 11:22 PM
    in my language version of wikipedia it says (uncited) that one of the advantages of hypertext is reducing redundancy but that's not really what people on the web do. We have timelines and aggregations where individual listings are as good as the representation they link to
  • e

    echoing-book-71490

    12/09/2022, 11:23 PM
    like we need a better iframe, maybe a topic for #974086000307499028
  • m

    mysterious-toddler-20573

    12/09/2022, 11:24 PM
    well, for the concrete example given, I'd expect a URL like:
    Copy code
    https://somestore.com/products/32?variant=3
    with hypermedia controls that update that URL when necessary
  • e

    echoing-book-71490

    12/09/2022, 11:24 PM
    yeah, for that sure, no reason to make it more complicated than that in this example
  • m

    mysterious-toddler-20573

    12/09/2022, 11:25 PM
    I have, to some extent, used urls like
    /someresource/<id>/somesubresrouce/<sub-id>
  • m

    mysterious-toddler-20573

    12/09/2022, 11:25 PM
    and htmx tends to push your towards more fine grain URLs for "sub-resources"
  • m

    mysterious-toddler-20573

    12/09/2022, 11:25 PM
    but there is no system that is perfect, for sure
  • e

    echoing-book-71490

    12/09/2022, 11:26 PM
    there isn't
  • e

    echoing-book-71490

    12/09/2022, 11:27 PM
    I'm not sure how you could push devs to actually update the url when it's optional, outside of being a complete jerk and blocking updates without doing it
  • m

    mysterious-toddler-20573

    12/09/2022, 11:27 PM
    (well, except hyperscript, obviously)
  • a

    aloof-scooter-64677

    12/10/2022, 2:33 AM
    Hey What would be the basy way to use htmx with golang. Go html/templates is not as suited for partial rendering as django's is. So I was wondering how others do it.
  • m

    mysterious-toddler-20573

    12/10/2022, 4:02 AM
    question for the group re: idiomorph https://twitter.com/htmx_org/status/1601415964544753665
  • p

    polite-glass-80210

    12/10/2022, 5:06 AM
    Hi there, I have a fairly complex/dynamic WordPress site that loads initial static html (which differs for each page, for each user) and then also automatically fills in various dynamic sections via jquery ajax calls to the server, which returns HTML that is simply added to the DOM. Likewise, when user actions are taken (submit a form, etc...), ajax submits the relevant data to the server and, if necessary, the DOM is updated with generated HTML. I'm quite content with this for the most part, but the biggest issue is that these dynamic requests are enormously redundant - they just re-generate the same data over and over again on the server-side. So, I'm planning to implement a sort of dynamic caching mechanism that will store the HTML fragments once - first on the server/backend side and then also in the browser storage (IndexedDB). A service worker in the browser, along with probably some sort of backend API, will intercept these enormously redundant AJAX requests and fill them with the cached HTML. As part of this effort, I'm assessing other tools and techniques and HTMX and the whole concept of HTML over the Wire is one of the main things that strikes me as attractive. Does this, in a sense, "qualify" for the sorts of sites/standards that are being worked on with HTMX? It's not even clear to me what benefits HTMX would afford me given that its already essentially HTML over the wire. Yet, I'm sure there's plenty that I'm simply not appreciate yet, so any thoughts would be appreciated! Thanks!
  • b

    brash-house-85887

    12/10/2022, 5:11 AM
    Why would you create your own browser-side caching mechanism? HTTP already has that all baked in and htmx supports it https://htmx.org/docs/#caching
  • b

    brash-house-85887

    12/10/2022, 5:13 AM
    I'd imagine one benefit of htmx would be observability. Sounds like your current solution uses some hand-written JS to handle the AJAX requests. With htmx you could put all that in the hx- tags and maybe end up with less custom code.
  • p

    polite-glass-80210

    12/10/2022, 5:21 AM
    Thanks! Currently essentially none of the AJAX-loaded stuff gets cached at all. Partly because they use POST requests, but I suspect for other reasons as well. Whatever the case, I definitely need to implement some backend caching of the generated-html - it should reduce server costs and speed up page loads immensely. Also, I intend to use the browser cached data (again, in IndexedDB, not the Cache API) in various ways as well - probably via Javascript. I intend to create a full-fledged PWA from this. Anyway, I think I'm starting to appreciate the value of HTMX from your second line (as well as continuing to read the docs, watch some videos etc... Its perhaps achieving something very similar - HTML fragments over the wire - but can do so by adding minimal extra code to the HTML templates rather than writing a bunch of JS eventlisteners that update the DOM. Is that right? If so, if I were to build a site like this today, it seems like it would make complete sense to use HTMX to its fullest capabilities to reduce/eliminate the JS code. Unfortunately its not something that I have any time for at the moment
  • b

    brash-house-85887

    12/10/2022, 5:27 AM
    Yep, a few extra html attributes can replace a good amount of hand-written JS. Also, if you wanted to implement your own caching you might check into htmx's extension support, it seems pretty nice. Regardless, htmx also plays nicely with JS so I imagine you could probably figure out a way to implement your own custom caching there too. https://htmx.org/events/#htmx:beforeRequest
  • b

    brash-house-85887

    12/10/2022, 5:30 AM
    (I imagine an extension would use that JS "API", but my point was that you don't need to create an extension if you don't want to.)
  • p

    polite-glass-80210

    12/10/2022, 5:38 AM
    Thanks very much! I'll have to explore the docs and extensions in more detail tomorrow. Though, in all likelihood, I won't use HTMX at all at first - I'll just focus on getting the various caching things set up in a sort of "drop-in" manner so as to not disturb the many plugins from different developers that are all working together reasonably harmoniously. But, it'll be good to be familiar with what HTMX can do for future custom development that I do, as well as for perhaps an entire custom re-write someday. Thanks again!
  • b

    brash-house-85887

    12/10/2022, 5:45 AM
    Have fun! (And good luck with your caching. Remember, there are two hard things in computer science: cache invalidation, naming things and off-by-one errors.)
  • p

    polite-glass-80210

    12/10/2022, 6:14 AM
    haha, yes - I'm aware of the prime difficulty of invalidation, though don't yet have much appreciation for what that will actually entail. At the same time, I'm not sure that I will need to be too picky about it. I'm sure I'll find out soon enough...
  • p

    polite-glass-80210

    12/10/2022, 6:23 AM
    p.s. for anyone who care about this topic, this article, in particular, clarified things for me https://htmx.org/essays/locality-of-behaviour/
  • f

    freezing-controller-74032

    12/10/2022, 7:50 AM
    Guys help me. How can I change two different blocks with one request and one response? How should I return the response in one response? For example, I have two div #div1 #div2 I want to change them to #div1-new #div2-new How to divide the answer between these two blocks so that each block takes what is intended for it?
  • m

    mammoth-family-48524

    12/10/2022, 8:32 AM
    https://htmx.org/attributes/hx-swap-oob/
  • f

    freezing-controller-74032

    12/10/2022, 8:36 AM
    I have already been advised this but I do not understand how to use it ? Should I return all new blocks together in one response like HTML code ? Like this
    m
    • 2
    • 16
  • m

    mammoth-family-48524

    12/10/2022, 9:10 AM
    I have already been advised this but I
  • b

    bitter-carpet-58319

    12/10/2022, 12:03 PM
    Beginner [zero JS knowledge] - Have multiple where more and more specifying product via hx-post and hx-target, this work fine. Output of LAST hx-post should be POSTed to server too, but reply should goes to another . In old version this was done by . How can this be done by HTMX? Doubting the htmx can hadle frames, so only solution I can see is to 'put' output from last to but could this be done without by plain HTMX [without additional JS]? Or should I choose some different apporoach?
  • m

    mysterious-toddler-20573

    12/10/2022, 5:55 PM
    https://mobile.twitter.com/htmx_org/status/1601575615983144966
  • t

    tall-dinner-62086

    12/10/2022, 6:57 PM
    Have you tried just
    hx-target="frame"
    ?
  • b

    bitter-carpet-58319

    12/10/2022, 7:44 PM
    not yet, still only thinking about concept. Found nothing about FRAME support in the documentation.
1...940941942...1146Latest