Skip to content

Instantly share code, notes, and snippets.

@zackify
Created May 10, 2020 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackify/266d6fe5eddc1d00938cbda4d37b40ec to your computer and use it in GitHub Desktop.
Save zackify/266d6fe5eddc1d00938cbda4d37b40ec to your computer and use it in GitHub Desktop.
Example loading module vs no module
(function(d) {
var script = d.createElement("script");
script.type = "text/javascript";
script.text =
'import("https://passwordless.app/account/module/integrated.js");window.supportsDynamicImport = true;';
d.getElementsByTagName("head")[0].appendChild(script);
var script2 = d.createElement("script");
script2.type = "text/javascript";
script2.text =
'if (!window.supportsDynamicImport) {const systemJsLoaderTag = document.createElement("script");systemJsLoaderTag.src = "https://unpkg.com/systemjs@2.0.0/dist/s.min.js";systemJsLoaderTag.addEventListener("load", function() {System.import("https://passwordless.app/account/nomodule/integrated.js");});document.head.appendChild(systemJsLoaderTag);}';
d.getElementsByTagName("head")[0].appendChild(script2);
var link = d.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = "https://passwordless.app/fonts/fonts.css";
d.getElementsByTagName("head")[0].appendChild(link);
})(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment