rsnext/packages/next/client/dev/fouc.js
JJ Kasper 04f1dd52b9 Delay hydration until after page is visible in development (#10164)
* Delay hydration until after page is visible in development

* Tweak dead-code elimination
2020-01-20 21:41:41 +01:00

17 lines
504 B
JavaScript

export function displayContent(callback) {
// This is the fallback helper that removes Next.js' no-FOUC styles when
// CSS mode is enabled. This only really activates if you haven't created
// _any_ styles in your application yet.
;(window.requestAnimationFrame || setTimeout)(function() {
for (
var x = document.querySelectorAll('[data-next-hide-fouc]'), i = x.length;
i--;
) {
x[i].parentNode.removeChild(x[i])
}
if (callback) {
callback()
}
})
}