Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of lib during initialization phase #2045

Merged
merged 5 commits into from
Dec 5, 2023

Conversation

mihalikv
Copy link
Contributor

Description

If I have following page:

<div hx-boost="true">
    <a href="https://htmx.org/">asdasdasd</a>
</div>
<a href="https://www.google.com/">test</a>
... thousand of same link
<a href="https://www.google.com/">test</a> 

htmx on load will init all of the links on the page. However, it's necessary to init htmx only on one link inside hx-boost wrapper. This can result in poor performance on pages with lot of "plain" links.

Performance on page with 1K links (6 x slowdown):
Before:
image

After:
image

Testing

I have test the performance and simple boosted link.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue - I hope that it's bugfix
  • I ran the test suite locally (npm run test) and verified that it succeeded

src/htmx.js Outdated Show resolved Hide resolved
src/htmx.js Outdated Show resolved Hide resolved
src/htmx.js Outdated Show resolved Hide resolved
@Telroshan
Copy link
Collaborator

Btw, is the performance still good with the requested changes @mihalikv ?
Just to make sure it still matches your initial intent, as the numbers above come from the first version of this PR if I'm not mistaken

@alexpetros
Copy link
Collaborator

Needs to be rebased but this is a good change

@mihalikv
Copy link
Contributor Author

mihalikv commented Dec 3, 2023

Btw, is the performance still good with the requested changes @mihalikv ? Just to make sure it still matches your initial intent, as the numbers above come from the first version of this PR if I'm not mistaken

Yeah it looks good.

@alexpetros alexpetros added the ready for review Issues that are ready to be considered for merging label Dec 3, 2023
@1cg 1cg merged commit 24b6ee1 into bigskysoftware:dev Dec 5, 2023
1 check passed
@mihalikv mihalikv deleted the init_perf branch December 6, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ready for review Issues that are ready to be considered for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants