gajus/youtube-player

Stop loading uselessly YouTube iframe_api

Open

#72 aperta il 19 set 2018

Vedi su GitHub
 (1 commento) (0 reazioni) (1 assegnatario)JavaScript (80 fork)github user discovery
enhancementhelp wanted

Metriche repository

Star
 (386 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Hi everyone,

I would like to point out that src/loadYouTubeIframeApi.js loads the iframe_api script unnecessarily even though window.YT is already defined.

In line 15, there is a check if (window.YT && window.YT.Player && window.YT.Player instanceof Function)...

and the line 36 which loads the script load(protocol + '//www.youtube.com/iframe_api', (error) => {...

isn't in a else statement attached to the condition of line 15, and it must be in my opinion because it will prevent making a request to YouTube which is exactly what i would like because not only i have all the needed scripts being previously loaded and already exposing window.YT, but the app that i'm building lives behind a proxy restraining all external requests

I could submit a PR for that. What do you think ?

Best regards

Guida contributor