Skip to content

Instantly share code, notes, and snippets.

@deminoth
Last active April 1, 2021 14:18
Show Gist options
  • Save deminoth/6df889c0d5e35b9f4b54 to your computer and use it in GitHub Desktop.
Save deminoth/6df889c0d5e35b9f4b54 to your computer and use it in GitHub Desktop.
카카오 자바스크립트 SDK 비동기로드 asynchronously load Kakao Javascript SDK
window.kakaoAsyncInit = function() {
Kakao.init('your-javascript-key');
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://developers.kakao.com/sdk/js/kakao.min.js";
var done = false;
js.onload = js.onreadystatechange = function() {
if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
done = true;
if(typeof window.kakaoAsyncInit === 'function') {
window.kakaoAsyncInit();
}
// Handle memory leak in IE
js.onload = js.onreadystatechange = null;
if ( fjs && js.parentNode ) {
fjs.parentNode.removeChild( js );
}
}
}
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'kakao-jssdk'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment