Skip to content

Commit c0c345f

Browse files
authored
Merge pull request #3590 from AryaXDG/fix/theme-cpu-spike-debounce
Fix: Add debouncing to theme updates to prevent CPU spike
2 parents 47371a1 + 6b08138 commit c0c345f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

js&css/web-accessible/core.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,11 @@ document.addEventListener('it-message-from-extension', function () {
255255
case 'themePrimaryColor':
256256
case 'themeSecondaryColor':
257257
case 'themeTextColor':
258-
ImprovedTube.myColors();
259-
ImprovedTube.setTheme();
258+
clearTimeout(ImprovedTube.themeUpdateTimer);
259+
ImprovedTube.themeUpdateTimer = setTimeout(function () {
260+
ImprovedTube.myColors();
261+
ImprovedTube.setTheme();
262+
}, 200);
260263
break
261264

262265
case 'description':
@@ -581,4 +584,4 @@ ImprovedTube.messages.send = function (message) {
581584

582585
document.dispatchEvent(new CustomEvent('it-message-from-youtube'));
583586
}
584-
};
587+
};

0 commit comments

Comments
 (0)