Skip to content

Commit 16dfaf2

Browse files
committed
implement low priority startup
1 parent 57ae4e5 commit 16dfaf2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import pageService, { PageState } from "./Services/PageService";
77
import persistenceService from "./Services/PersistenceService";
88

99
console.log("script start");
10-
setTimeout(() => {
10+
11+
if (document.location.pathname.length > 1 && 'requestIdleCallback' in window) {
12+
requestIdleCallback(startup, { timeout: 300000 });
13+
} else {
14+
setTimeout(startup, 0);
15+
}
16+
17+
function startup() {
1118
pageService.updateNativeStyleRuleModifications(PageState.LOADING);
1219

1320
const ytbspComponent = new YTBSPComponent();
@@ -43,4 +50,4 @@ setTimeout(() => {
4350
pageService.addThumbnailEnlargeCss();
4451
}).catch(e => console.error(e));
4552

46-
}, 0);
53+
}

0 commit comments

Comments
 (0)