Skip to content

Instantly share code, notes, and snippets.

@ironhack-edu
Forked from kentcdodds/append-div.js
Created December 19, 2020 22:42
Show Gist options
  • Save ironhack-edu/38a3b208bd2d7e74d688841576cda4dd to your computer and use it in GitHub Desktop.
Save ironhack-edu/38a3b208bd2d7e74d688841576cda4dd 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