Created
October 7, 2019 18:14
-
-
Save johnborges/7b49a3481be307849d56da698ca0c5d9 to your computer and use it in GitHub Desktop.
Evaluating JavaScript using the import() statement
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
const js = `console.log('Hello everyone!');`; | |
const encodedJs = encodeURIComponent(js); | |
const dataUri = 'data:text/javascript;charset=utf-8,' | |
+ encodedJs; | |
import(dataUri); | |
// Output: | |
// 'Hello everyone!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment