Skip to content

Instantly share code, notes, and snippets.

@kevincennis
Created November 21, 2017 20:08
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 kevincennis/a2afabe326a9cd65f6de0e57d5971379 to your computer and use it in GitHub Desktop.
Save kevincennis/a2afabe326a9cd65f6de0e57d5971379 to your computer and use it in GitHub Desktop.
dynamic import feature detection
function hasDynamicImport() {
try {
const f = new Function( 'x', 'return import("foo")' );
return true;
} catch ( err ) {
if ( err instanceof SyntaxError ) {
return false;
}
return true;
}
};
hasDynamicImport();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment