-
Notifications
You must be signed in to change notification settings - Fork 11
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
On initial page load run init before turbo:load has been fired #646
Conversation
… feature/load-vue-quick
document.addEventListener('turbo:load', init) | ||
setTimeout(init) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This specific order of setTimeout and requestAnimationFrame ensures LCP is not impacted.
And ensures small task time for the turbo:load
/evaluate script, and vue:loaded
events by scheduling them all in their own task.
Using a setTimeout for both, a requestAnimationFrame for both, or executing this immediately and booting Vue in a requestAnimationFrame all has impact on the LCP
So this is still work in progress? Is it tested within a real project? |
Yes it has been tested (though locally) with both a clean Rapidez installation, and a couple of real projects without issue. |
I'll change it to a draft, please mark it when it's ready to merge |
It seems the tests were caused by the order that event listeners were being applied in. Loading turbo lazily fixes this issue. |
This will make Rapidez initialize before marketing scripts, browser extensions and other scripts run.
Improving startup times of Rapidez.
Before:
After:
Currently as draft as we should figure out the best method/event to run this on in order not to impact LCP