regex-search
regex-search copied to clipboard
Potential performance optimizations
I neither faced any performance issues myself nor did I run extensive benchmarks on what I'm suggesting.
The points do not come from my personal experience either, some are even rather hearsay so take it with a grain of salt.
- During scrolling it looks like you j-query both the elements and the body just to use the jQuery methods
.scrollTop()and.offset(). Vanilla JS might bring performance gains here. - In
recurseyou also j-query each element and then use.css()to access theirdisplaystyle. Plain vanilla JSshould also be more performant here. - In
elementInViewportyou walk up the parent chain.getBoundingClientRect()should usually be more performant.
I did see JSPerfs supporting these claims at least on my machine and current browser so I might (or might not) add them here later.
Again: I neither reviewed those JSPerfs, nor did I run them on multiple browsers or devices, nor did I performance-test in the context of your code.