I have a script off site for a Schema (structured data). My Antiquated CMS does not recognize HTML5 and will modify Javascript in the html so I have to have it in a separate file. The problem is google does not find the external file. I read I should have it "dynamically injected into the page's contents" What is the best way to do this?

2 Answers 2


Well, I found it on my own. If anyone else has the same question:

var element = document.createElement("script");
element.setAttribute("src", "path-file.js");

I'm a javascript novice so I had to research a bit. Works great.

  • While this works as far as the external file loads, search engines don't recognize the schema in this way, so it doesn't really solve my problem.
    – brian11811
    Commented Aug 16, 2018 at 21:18

Good to know you have already figured it out. But you can also insert JavaScript Code through Google Tag Manager instead of putting it at 3rd place externally, inject it through GTM.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.