Last active
June 2, 2017 16:58
-
-
Save eeeps/c89b9ef28928f2eb5e7db5294be70666 to your computer and use it in GitHub Desktop.
Can we initialize a ResizeObserver in the head, and start observing elements as they are parsed on first load with a MutationObserver?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<head> | |
<title>FoUC-free container queries</title> | |
<script> | |
const ro = new ResizeObserver( ( entries) => { | |
// do container query stuff | |
} ); | |
const mo = new MutationObserver( ( mutations ) => { | |
// `ro.observe( relevantElement )`s as they are parsed and added to the DOM | |
} ); | |
mo.observe( document, { childList: true, subtree: true } ); | |
</script> | |
</head> | |
<body> | |
<p>Cool</p> | |
<p>refreshing</p> | |
<p>content</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment