Created
January 25, 2021 04:05
-
-
Save ardeearam/6e3940e4b621c3f4296f906a7be4a1dc to your computer and use it in GitHub Desktop.
lib/GoogleLogin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const loadGoogleScript = () => { | |
//loads the Google JavaScript Library | |
(function () { | |
const id = 'google-js'; | |
const src = 'https://apis.google.com/js/platform.js'; | |
//we have at least one script (React) | |
const firstJs = document.getElementsByTagName('script')[0]; | |
//prevent script from loading twice | |
if (document.getElementById(id)) { return; } | |
const js = document.createElement('script'); | |
js.id = id; | |
js.src = src; | |
js.onload = window.onGoogleScriptLoad; | |
firstJs.parentNode.insertBefore(js, firstJs); | |
}()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment