Gatsby 5 - No longer able to retrieve script src's from getPostBodyComponents in onPreRenderHTML #37036
Replies: 3 comments 6 replies
-
What script and what performance benefit?
No, I can't think of a way to access that anymore |
Beta Was this translation helpful? Give feedback.
-
When this first was brought up we actually looked into what it would take to support the access to this again. It would take some effort and we're not sure about the benefit of it. As per @mlgualtieri recommendation he only lists third-party resources in CSP, not e.g. the ones from Gatsby. So can you please elaborate why you'd need to list Gatsby's script for CSP. |
Beta Was this translation helpful? Give feedback.
-
Personally - I would like this as an easy way to inject some attributes on the |
Beta Was this translation helpful? Give feedback.
-
Since the introduction of the ServerSliceRenderer in Gatsby 5 it appears the method for rendering the core Gatsby scripts via the
onPreRenderHTML
API has changed.Previously I could retrieve the following scripts from the
getPostBodyComponents
ingatsby-ssr
:webpack-runtime-*.js
app-*.js
I would filter these scripts from
getPostBodyComponents()
and reuse them in a custom script for performance benefits.In Gatsby 5 however, these scripts no longer appear in
getPostBodyComponents()
. From what I can tell those scripts are being generated through the new slice API.Gatsby 5 Log
The inline script here is used for CDATA.
Gatsby 4 Log
Is there any way I can retrieve the script src like was possible in Gatsby 4?
Beta Was this translation helpful? Give feedback.
All reactions