Created
July 16, 2019 20:49
-
-
Save acabreragnz/80c4d74247fef2b269a1823552605e3c to your computer and use it in GitHub Desktop.
Simple example about creating embed code
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
// index.html | |
// embed code | |
<script type="text/javascript" id="hs-script-loader" async defer src="//online-script.com/script-loader/XXXX.js"></script> | |
// online-script.com/script-loader/XXXX.js | |
(function (id, src) { | |
if (document.getElementById(id)) { return; } | |
var js = document.createElement('script'); | |
js.src = src; | |
js.type = 'text/javascript'; | |
js.id = id; | |
var e = document.getElementsByTagName('script')[0]; | |
e.parentNode.insertBefore(js, e); | |
})('my-script', '//online-script.com/script/YYYY.js'); | |
// online-script.com/script/YYYY.js | |
// ... THE ENTIRE CODE GOES HERE ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment