DEV Community

Discussion on: Add Custom JavaScript to a Gatsby Site

Collapse
 
itmayziii profile image
Tommy May III

Please try and avoid ejecting html.js unless you have to. The out of the box APIs could accomplish adding a script to the head
gatsbyjs.org/docs/ssr-apis/#onRend...

Collapse
 
mercatante profile image
Steven Mercatante

Hi Tommy, thanks for mentioning onRenderBody. You're right that it can be used to render custom scripts in the head, but I still think there's value in knowing how to manually tweak html.js for fine-grained control. I'll update this article to include an example using onRenderBody, though.