Skip to content

Commit d545e12

Browse files
committed
Fix: open chrome start up speed optimize
1 parent 777fefb commit d545e12

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/popup/script/loadGithubStar.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
// 检测是否为 Edge 浏览器
2-
const isEdge = navigator.userAgent.indexOf("Edg") !== -1;
31

42
// 设置更短的超时时间
5-
const TIMEOUT_DURATION = isEdge ? 1000 : 3000;
3+
const TIMEOUT_DURATION = 500 ;
64

75
function loadGithubStar() {
86
const container = document.getElementById('github-star-container');
97
if (!container) return;
108

11-
// 如果是 Edge 浏览器且无法快速加载,直接显示静态按钮
9+
// 如果浏览器且无法快速加载,直接显示静态按钮
1210
const timeout = setTimeout(() => {
1311
container.innerHTML = `
1412
<a href="https://github.com/xiaohajiayou/Leetcode-Mastery-Scheduler"
@@ -38,14 +36,5 @@ function loadGithubStar() {
3836
container.appendChild(iframe);
3937
}
4038

41-
// Edge 浏览器使用更快的加载策略
42-
if (isEdge) {
43-
setTimeout(loadGithubStar, 100);
44-
} else {
45-
// 其他浏览器使用 requestIdleCallback
46-
if ('requestIdleCallback' in window) {
47-
requestIdleCallback(loadGithubStar, { timeout: 1000 });
48-
} else {
49-
setTimeout(loadGithubStar, 500);
50-
}
51-
}
39+
40+
setTimeout(loadGithubStar, 100);

0 commit comments

Comments
 (0)