Next.js Discord

Discord Forum

how to implement an external script in the build

Unanswered
Argentine ant posted this in #help-forum
Open in Discord
Argentine antOP
Hello,
We need to integrate an external tracking library (https://developers.atinternet-solutions.com/piano-analytics/data-collection/sdks/javascript) into our project
but unfortunately we can't install this dependency via npm.
We'd like to embed it in the final production build, without importing it in a script tag, to avoid the browser having to make an HTTP request.
We were thinking of injecting the library script into a script tag with the dangerouslySetInnerHTML property, but we don't know if this is a good way to do it.
Also, we don't know if it's a good idea not to use the browser's caching logic.
What do you think? Have you ever had this problem and how did you solve it?

0 Replies