Created
November 21, 2017 20:08
-
-
Save kevincennis/a2afabe326a9cd65f6de0e57d5971379 to your computer and use it in GitHub Desktop.
dynamic import feature detection
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
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