Next.js Discord

Discord Forum
","dateCreated":"2023-10-27T20:15:27.000Z","answerCount":0,"author":{"@type":"Person","name":"Rex"}}}

How to show the third-party widjet when change locale?

Unanswered
Rex posted this in #help-forum
Open in Discord
RexOP
Hello community!
I have a problem that I can not solve on my own:
I connected the third-party helpcrunch widget to the project using Script from "next/script"; I need it on all pages, so I put it in the root layout. This widget works, but when I change the language of the site to another and the page is rerendered, the widget is no longer there, because the Script does not reload. What can you advise? The onReady attribute in the Script does not help.

my scripts:

<Script id="helpcrunchSettings" type="text/javascript">
{window.helpcrunchSettings = { organization: '', appId: '',};}
</Script>

<Script id="helpcrunchWidjet" type="text/javascript">
{(function(w,d){var hS=w.helpcrunchSettings;if(!hS||!hS.organization){return;}var widgetSrc='https://'+hS.organization+'.widget.helpcrunch .com/';w.HelpCrunch=function(){w.HelpCrunch.q.push(arguments)};w.HelpCrunch.q=[];function r(){if (d.querySelector('script[src= "' + widgetSrc + '"')) { return; }var s=d.createElement('script');s.async=1;s.type='text/javascript';s.src=widgetSrc;(d .body||d.head).appendChild(s);}if(d.readyState === 'complete'||hS.loadImmediately){r();} else if(w.attachEvent){w.attachEvent( 'onload',r)}else{w.addEventListener('load',r,false)}})(window, document)}
</Script>

0 Replies