Skip to content

Commit

Permalink
Add requestIdleCallback polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Richard committed May 9, 2024
1 parent 0050786 commit d7038a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions site/src/components/home/AnimatedHero.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@
* Wait for the component to mount before loading Lottie
*/
onMount(async () => {
// Load the polyfill if requestIdleCallback isn't supported
if (!('requestIdleCallback' in window)) {
import('requestidlecallback');
}
// Polyfill for Safari
await import('requestidlecallback');
// Kick off the animation loading
requestIdleCallback(() => {
Expand Down
8 changes: 3 additions & 5 deletions site/src/js/paint.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'requestidlecallback';

window.addEventListener('load', () => {
if ('requestIdleCallback' in window) {
requestIdleCallback(paintSetup);
} else {
paintSetup();
}
requestIdleCallback(paintSetup);
});

/**
Expand Down

0 comments on commit d7038a3

Please sign in to comment.