Skip to content

Instantly share code, notes, and snippets.

@Narigo
Created January 21, 2021 19:46
Show Gist options
  • Save Narigo/670e39d7d6d456db9c5e07ae78b7adc7 to your computer and use it in GitHub Desktop.
Save Narigo/670e39d7d6d456db9c5e07ae78b7adc7 to your computer and use it in GitHub Desktop.
data URIs are working in the browser 🤯
<!DOCTYPE html>
<html>
<body>
seeing the alert?
<script src="main.js" type="module"></script>
</body>
</html>
import somethingFromADataUrl from "data:application/javascript;charset=utf-8;base64,ZXhwb3J0IGRlZmF1bHQgJ2Zhc3QtZmlsZSc7";
alert(JSON.stringify({ somethingFromADataUrl }));
@Narigo
Copy link
Author

Narigo commented Jan 21, 2021

Only working when served through a HTTP server, not as a file:///somewhere/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment