Skip to content

Instantly share code, notes, and snippets.

@davidbgk
Created May 10, 2016 16:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidbgk/37ab1d4bc21d76e6281c700884fc5cbf to your computer and use it in GitHub Desktop.
Save davidbgk/37ab1d4bc21d76e6281c700884fc5cbf to your computer and use it in GitHub Desktop.
Test DOM Content Loaded and promises
<!doctype html>
<meta charset=utf-8>
<title>Test DOM Content Loaded and promises</title>
<script>
console.log(document.querySelector('main')) // => null
document.ready = new Promise(
(resolve) => document.addEventListener('DOMContentLoaded', resolve))
document.ready.then(() => console.log(document.querySelector('main'))) // => <main>
</script>
<main></main>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment