Next.js Discord

Discord Forum

schema.org scripts bloating the page issue

Unanswered
Sweat bee posted this in #help-forum
Open in Discord
Sweat beeOP
I use the script component to load json ld schema.org data into certain pages. The docs (https://nextjs.org/docs/app/building-your-application/optimizing/scripts#application-scripts) recommend to load the scripts in specific pages or layouts which I do. I even load some of them in certain components. The problem is the site has a lot of faq pages for different areas and each faq has its own script. After browsing a while all the scripts are just being added to the body of the page but never removed from it. I can understand it does not make sense for certain scripts to remove and reload them over and over again but in this case it would probably because there is not much the script does except of setting the structured data string. Is there a way to solve this or can I just ignore the fact that I have around 100 scripts loaded after I visited every single page?! And how is google treating this? I guess google just sees every page individually as I would do a page refresh on each page (then only the scripts are loaded which should be loaded)?!

0 Replies