Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function appendDiv(message) {
const div = document.createElement('div')
div.textContent = message
document.body.appendChild(div)
}
export {appendDiv}
import {appendDiv} from './append-div.js'
function go() {
appendDiv('Hello from async script')
}
export {go}
<script type="module">
import {appendDiv} from './append-div.js'
appendDiv('Hello from inline script')
</script>
<script type="module" src="./script-src.js"></script>
import {appendDiv} from './append-div.js'
appendDiv('Hello from external script')
import('./async-script.js').then(
moduleExports => {
moduleExports.go()
},
error => {
console.error('there was an error loading the script')
throw error
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.