Repository navigation
Load features faster - #4316
Load features faster#4316
Conversation
| while (!document.body) { | ||
| // eslint-disable-next-line no-await-in-loop | ||
| await Promise.race([delay(10), frame()]); | ||
| } |
There was a problem hiding this comment.
If frame resolves, we definitely have body too.
| while (!document.body) { | |
| // eslint-disable-next-line no-await-in-loop | |
| await Promise.race([delay(10), frame()]); | |
| } | |
| const oneFrame = frame(); | |
| while (!document.body) { | |
| // eslint-disable-next-line no-await-in-loop | |
| await Promise.race([delay(10), oneFrame]); | |
| } |
Maybe there's a "better" way to write it though
| while (!document.body) { | |
| // eslint-disable-next-line no-await-in-loop | |
| await Promise.race([delay(10), frame()]); | |
| } | |
| await Promise.race([frame(), pWaitFor(() => document.body)]); |
but unless we already have the dependency, I'd rather not
There was a problem hiding this comment.
but unless we already have the dependency
its not
|
Title good? |
|
I have a hunch about what's causing the issue here: Firefox is easily tricked into rendering the content before it's ready, therefore resolving the We had this issue in Refined GitHub before but I don't remember what caused it. I think some extensions are triggering this behavior and wreaking havoc in the loop. Can you restore this PR and instead use code like: await Promise.race([
// With comments
elementReady('body', {waitForChildren: false})
// Maybe written better?
(async () => {
while (!document.body) {
await delay(10);
}
})()
]); |
Closes #4312
From 280ms to 39.458984375 ms
Test URLs
All
Screenshot
None