Skip to content

Instantly share code, notes, and snippets.

@Claire
Forked from kentcdodds/append-div.js
Created April 19, 2021 03:01
Show Gist options
  • Save Claire/de7a11e63a428dfb8cdcdd5c1f8ba11d to your computer and use it in GitHub Desktop.
Save Claire/de7a11e63a428dfb8cdcdd5c1f8ba11d to your computer and use it in GitHub Desktop.
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