Skip to content

Commit e62663a

Browse files
committed
Don't load spotify script unless actually necessary
1 parent 0e36eba commit e62663a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/spotify.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ const IFrameAPI = shallowRef<IFrameAPI>();
2828
window.onSpotifyIframeApiReady = api => {
2929
IFrameAPI.value = api;
3030
};
31-
const { load: loadSpotify } = useScriptTag('https://open.spotify.com/embed/iframe-api/v1', () => {}, { manual: true });
32-
loadSpotify();
31+
let spotifyLoaded = false;
3332

3433
export function useSpotifyIFrameAPI() {
34+
if (!spotifyLoaded) {
35+
spotifyLoaded = true;
36+
const { load: loadSpotify } = useScriptTag('https://open.spotify.com/embed/iframe-api/v1', () => {}, { manual: true });
37+
loadSpotify(false);
38+
}
3539
return IFrameAPI;
3640
}

0 commit comments

Comments
 (0)