Loading a third party form script on a static page
Unanswered
Colombian fino hound posted this in #help-forum

Colombian fino houndOP
We are loading a third party form using JS on some of our pages. But Google Page Speed is flagging us due to "Remove the impact of third party code" -- what would be the best way to load the following script in Next JS? <div data-paperform-id="xxxxxx"></div><script>(function() {var script = document.createElement('script'); script.src = "https://paperform.co/__embed.min.js"; document.body.appendChild(script); })()</script>
3 Replies

@Colombian fino hound We are loading a third party form using JS on some of our pages. But Google Page Speed is flagging us due to "Remove the impact of third party code" -- what would be the best way to load the following script in Next JS? <div data-paperform-id="xxxxxx"></div><script>(function() {var script = document.createElement('script'); script.src = "https://paperform.co/__embed.min.js"; document.body.appendChild(script); })()</script>

instead of creating another script tag inside your script tag, you can create the expected script directly like this:
<Script src={"https://paperform.co/__embed.min.js"}></Script>

Colombian fino houndOP
For a static page, where is the best place to put these so they are non-render blocking?

@Colombian fino hound For a static page, where is the best place to put these so they are non-render blocking?

if you using the
Script
tag, nextjs will automatically place it at the correct position