Skip to content

Instantly share code, notes, and snippets.

@mike-clark-8192
Last active December 31, 2025 04:34
Show Gist options
  • Select an option

  • Save mike-clark-8192/359b8bddbdcb87bf4382da76720db0b5 to your computer and use it in GitHub Desktop.

Select an option

Save mike-clark-8192/359b8bddbdcb87bf4382da76720db0b5 to your computer and use it in GitHub Desktop.
(async function() {
const [fileHandle] = await window.showOpenFilePicker({
types: [{
description: 'JavaScript files',
accept: {'text/javascript': ['.js']}
}]
});
const file = await fileHandle.getFile();
const contents = await file.text();
console.log('Loaded:', file.name, contents.length, 'chars');
// Blob URL
const blob = new Blob([contents], {type: 'application/javascript'});
const url = URL.createObjectURL(blob);
const script = document.createElement('script');
script.src = url;
script.onload = () => {
URL.revokeObjectURL(url);
console.log('✓ Loaded via blob URL');
};
script.onerror = () => {
URL.revokeObjectURL(url);
console.error('✗ Blob URL failed');
};
document.head.appendChild(script);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment