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

    mysterious-toddler-20573

    12/08/2022, 6:36 PM
    405KB page is livin large 🙂
  • m

    mysterious-toddler-20573

    12/08/2022, 6:37 PM
    OK, so we can avoid dispatching that event, but we do need to scrub the page for event listeners.
  • t

    thankful-addition-60522

    12/08/2022, 6:38 PM
    still waiting on that es3/es5 version
  • l

    lemon-rocket-71964

    12/08/2022, 6:38 PM
    Right it is huge DOM :). We cannot swap blinding with performing the cleanup call?
  • m

    mysterious-toddler-20573

    12/08/2022, 6:39 PM
    https://github.com/bigskysoftware/htmx/blob/30f762aa47ed8aa502eca5ea957e9cb800cdb374/src/htmx.js#L883
  • m

    mysterious-toddler-20573

    12/08/2022, 6:39 PM
    we can avoid triggering that event
  • m

    mysterious-toddler-20573

    12/08/2022, 6:39 PM
    one sec
  • m

    mysterious-toddler-20573

    12/08/2022, 6:39 PM
    but not the cleanup
  • m

    mysterious-toddler-20573

    12/08/2022, 6:39 PM
    can I ask you to commend out the event dispatch and see what the profile looks like?
  • m

    mysterious-toddler-20573

    12/08/2022, 6:39 PM
    let's see if it's worth making that configurable
  • l

    lemon-rocket-71964

    12/08/2022, 6:40 PM
    Sure I will give a try
  • m

    mysterious-toddler-20573

    12/08/2022, 6:40 PM
    the bottom-up view indicates that will help a lot
  • m

    mysterious-toddler-20573

    12/08/2022, 6:40 PM
    and, if so, we can make that event cancellable
  • m

    mysterious-toddler-20573

    12/08/2022, 6:41 PM
    tbh, it's kind of dumb how it works b/c it will trigger O(n*log(n)) events on elements in the tree due to bubbling
  • m

    mysterious-toddler-20573

    12/08/2022, 6:41 PM
    ahhhh
  • m

    mysterious-toddler-20573

    12/08/2022, 6:42 PM
    maybe we can make that event not bubble
  • m

    mysterious-toddler-20573

    12/08/2022, 6:42 PM
    OK, comment that out and lmk what the perf looks like
  • l

    lemon-rocket-71964

    12/08/2022, 6:43 PM
    You want me to comment out the cleanupElement call?
  • m

    mysterious-toddler-20573

    12/08/2022, 6:44 PM
    comment out the event dispatch: https://github.com/bigskysoftware/htmx/blob/30f762aa47ed8aa502eca5ea957e9cb800cdb374/src/htmx.js#L882
  • l

    lemon-rocket-71964

    12/08/2022, 6:46 PM
    Got it. Give me a min I will share the profile.
  • l

    lemon-rocket-71964

    12/08/2022, 6:47 PM
    Yes it is working as fast the first load.
  • m

    mysterious-toddler-20573

    12/08/2022, 7:08 PM
    OK, next trick, can you change the "bubbles" option to "false" here temporarily: https://github.com/bigskysoftware/htmx/blob/30f762aa47ed8aa502eca5ea957e9cb800cdb374/src/htmx.js#L1858
  • m

    mysterious-toddler-20573

    12/08/2022, 7:09 PM
    and rerun the test
  • m

    mysterious-toddler-20573

    12/08/2022, 7:09 PM
    if that is still acceptable perf, then we can make this an option for that event
  • l

    lemon-rocket-71964

    12/08/2022, 7:16 PM
    I tried change the "bubbles" option to "false". But second call is slow.
  • m

    mysterious-toddler-20573

    12/08/2022, 7:18 PM
    well shoot
  • m

    mysterious-toddler-20573

    12/08/2022, 7:31 PM
    ok, final idea, change
    cleanUpElement()
    to this:
    Copy code
    js
            function cleanUpElement(element, fireEvent) {
                if (fireEvent !== false) {
                    fireEvent = triggerEvent(element, "htmx:beforeCleanupElement");
                }
                triggerEvent(element, "htmx:beforeCleanupElement");
                deInitNode(element);
                if (element.children) { // IE
                    forEach(element.children, function(child) { cleanUpElement(child, fireEvent) });
                }
            }
  • m

    mysterious-toddler-20573

    12/08/2022, 7:32 PM
    and then write an event listener on the document to catch that event and call
    preventDefault()
    on it
  • m

    mysterious-toddler-20573

    12/08/2022, 7:32 PM
    if my logic is right, that should prevent all but the first instance of that event firing
  • l

    lemon-rocket-71964

    12/08/2022, 7:36 PM
    Sorry I am not sure how to do it. Is there any reference?
1...937938939...1146Latest