"off-main-thread" Scripts and other Head elements cannot be loaded conditionally in production #38454
Open
2 tasks done
Labels
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
type: bug
An issue or pull request relating to a bug in Gatsby
Preliminary Checks
Description
idle
andpost-hydrate
strategies, it does not work for ones with theoff-main-thread
strategy. The script will populate the DOM, but will not fire (so any JS it contains will not run).meta
tags also does not work and the elements will never populate the DOM. This is also true for changing attributes within elements, such as the value of a "content" attribute which will never take effect.These issues do not occur in development - only when using
gatsby build
. They are not documented anywhere, which leads me to believe they may be unintended, but if they are intended they should be documented.The reproduction link below contains examples of these issues in various places to demonstrate context dependence.
Reproduction Link
https://codesandbox.io/p/sandbox/compassionate-julien-hyxk5h
Steps to Reproduce
In the Codesandbox:
yarn build && yarn serve
Expected Result
In the Codesandbox:
window.Bizible
should not beundefined
, since it is defined by the Bizible script loaded inpages/index.tsx
$.ajax
should be defined when called from the console, since it is defined by the Jquery script loaded in the Jquery component referenced ingatsby-browser
andgatsby-ssr
title
,meta
, and gstaticscript
tags should exist in Head as set in the SEO component.meta
robots tag show beindex
as set in the SEO componentgooglesyndication
script
should exist in head as set in the SEO componentActual Result
window.Bizible
is undefined despite the Bizible script appearing in the DOM$.ajax
is undefined despite the Jquery script appearing in the DOMtitle
,meta
, and gstaticscript
tags do not exist anywhere in the DOMmeta
robots tag remainsnoindex
indefinitelygooglesyndication
script
does not exist anywhere in the DOMEnvironment
Config Flags
No response
The text was updated successfully, but these errors were encountered: