Skip to content

Instantly share code, notes, and snippets.

@Danilovonline
Last active February 8, 2017 06:47
Show Gist options
  • Save Danilovonline/eeca0f0306def729de0b603c84e457f6 to your computer and use it in GitHub Desktop.
Save Danilovonline/eeca0f0306def729de0b603c84e457f6 to your computer and use it in GitHub Desktop.
Dynamic load JS file
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
var scheme = (document.location.href.indexOf('https://') === 0) ? 'https://' : 'http://';
s1.src = scheme + 'example.com/example.js';
s1.charset="UTF-8";
//s1.crossorigin="anonymous";
s0.parentNode.insertBefore(s1,s0);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment