Skip to content

Instantly share code, notes, and snippets.

@johnborges
Created October 7, 2019 18:14
Show Gist options
  • Save johnborges/7b49a3481be307849d56da698ca0c5d9 to your computer and use it in GitHub Desktop.
Save johnborges/7b49a3481be307849d56da698ca0c5d9 to your computer and use it in GitHub Desktop.
Evaluating JavaScript using the import() statement
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