Created
February 10, 2018 17:48
-
-
Save mikaelvesavuori/2334231ebf82fcadf049bf0afd9aab51 to your computer and use it in GitHub Desktop.
Check if ES6 is totally supported
This file contains hidden or 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
var supportsES6 = function() { | |
try { | |
new Function("(a = 0) => a"); | |
return true; | |
} | |
catch (err) { | |
return false; | |
} | |
}(); | |
if (supportsES6) { | |
var script = document.createElement("script"); | |
script.src = "my-es6-file.js"; | |
document.head.appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learned of this technique at: https://www.bram.us/2016/10/31/checking-if-a-browser-supports-es6/