Skip to content

Instantly share code, notes, and snippets.

@tagaroggu
Created June 21, 2021 01:30
Show Gist options
  • Save tagaroggu/57e9c18a626f970d69e22388f7aa16c0 to your computer and use it in GitHub Desktop.
Save tagaroggu/57e9c18a626f970d69e22388f7aa16c0 to your computer and use it in GitHub Desktop.
Experiments
<script>
var code = `
var string="banana";
var blob = new Blob([string], {type: 'text/plain'});
postMessage(URL.createObjectURL(blob));
`;
var worker = new Worker(URL.createObjectURL((new Blob([code], {type: 'application/javascript'}))));
worker.onmessage = _ => {
fetch(_.data).then(a=>a.text()).then(txt=>document.body.innerText = txt);
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment