1

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

1

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

<script>
var element = document.createElement("script");
element.setAttribute("src", "path-file.js");
document.getElementsByTagName("head")[0].appendChild(element);</script>

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

1
  • 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
    Aug 16, 2018 at 21:18
1

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.

0

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.