Closed iamakulov closed 4 years ago
I may be wrong, but using something like:
createPortal(<script .../>, document.body);
Works on SPA, but I don't know if it would work on SSR in Gatsby
Judging from quick googling, it wouldn’t :( createPortal
requires a DOM node, and there’re no DOM nodes on the server.
Yeah, createPortal would not work on SSR, too bad
Follow-up to #1.
In Chromium, on a slow connection, a script in the middle of the page blocks the rendering of the remaining page:
Even if it’s inline. Even if it’s
type="module"
and should be deferred.This PR fixes that by moving the script to
<head>
. (We’d better move it to the end of<body>
, but there’s no easy way to do that automatically.)