Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

🎨 Switch toVdom from array iteration to createTreeWalker #103

Merged
merged 16 commits into from
Apr 19, 2023

Conversation

luisherranz
Copy link
Member

@luisherranz luisherranz commented Nov 16, 2022

I have been testing createTreeWalker, and it is consistently faster than the for we are using now: 50% in Chrome and 15% in Firefox and Safari.

This PR is not ready to merge yet. I have opened it up with my tests if anyone wants to do theirs as well. I have also recorded a video explaining what I have done so far:

I won't be able to continue with this PR in the next few days, so if anyone wants to, you can finish it: remove the tests, delete old code, etc. I haven't tested the algorithm with HTML comments either, so we would have to test that it works before merging it. We also have to start thinking about adding tests (unit and e2e), but maybe that can be done in another PR.


Thanks to @michalczaplinski for the HTML file generator 🙂

@luisherranz luisherranz changed the title Switch from array (for loop) to createTreeWalker Switch toVdom from array iteration to createTreeWalker Nov 16, 2022
@luisherranz luisherranz changed the title Switch toVdom from array iteration to createTreeWalker 🎨 Switch toVdom from array iteration to createTreeWalker Nov 21, 2022
@luisherranz
Copy link
Member Author

I guess that the 5 heart reactions in the opening posts mean you all like it, so I'll clean it up, resolve the conflicts and prepare it for review 🙂

@SantosGuillamot
Copy link
Contributor

I loved the explanation 😁 And it seems faster, so I'm fine with pursuing this approach.

@luisherranz
Copy link
Member Author

I had to make a small adjustment to the algorithm and I added e2e tests (kudos to @DAreRodz for helping me with those). Both are explained in the video:

https://www.loom.com/share/45610946048c43d28adafb59e681245f

Ok. This is finally ready for review! 🎉

Copy link
Collaborator

@DAreRodz DAreRodz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's perfect, @luisherranz. 👌 Feel free to merge it.

@luisherranz luisherranz merged commit f1ccde9 into main-wp-directives-plugin Apr 19, 2023
@luisherranz luisherranz deleted the create-tree-walker branch April 19, 2023 08:13
@luisherranz
Copy link
Member Author

Thanks David!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants