Skip to content

Commit

Permalink
fix: conditionally loading iframe_api (#73)
Browse files Browse the repository at this point in the history
* [ISSUE-72] Conditionally loading iframe_api

* [ISSUE-72] Conditionally loading iframe_api

* [ISSUE-72] fixed linting errors
  • Loading branch information
mlnor27 authored and gajus committed Sep 25, 2018
1 parent 112f634 commit 97bdd36
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/loadYouTubeIframeApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export default (emitter: EmitterType): Promise<IframeApiType> => {
resolve(window.YT);

return;
} else {
const protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';

load(protocol + '//www.youtube.com/iframe_api', (error) => {
if (error) {
emitter.trigger('error', error);
}
});
}

const previous = window.onYouTubeIframeAPIReady;
Expand All @@ -31,13 +39,5 @@ export default (emitter: EmitterType): Promise<IframeApiType> => {
};
});

const protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';

load(protocol + '//www.youtube.com/iframe_api', (error) => {
if (error) {
emitter.trigger('error', error);
}
});

return iframeAPIReady;
};

0 comments on commit 97bdd36

Please sign in to comment.