I am working on a web-app that is using JSF 2.1 and RichFaces 3.3
I have an external piece of Javascript that needs to run across all of the applications' pages, so I put it in the head of my template file, call it layout.xhtml, 
This is used as the template by all of the different pages, so I think I've put it in the right place at least.
<ui:composition template="/templates/layout.xhtml">
The script itself is okay, tested it on JSFiddle and it runs as expected.
Its format is like so:
<script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js" 
        data-document-language="true" 
        type="text/javascript" 
        charset="UTF-8" 
        data-domain-script="dummy-value-for-stack-overflow">
</script>
When testing within the applcation, I was able to get the script to run fine on a normal .html page, however when I change to using a .xhtml page I am getting an error in the browser's console:
Uncaught (in promise) TypeError: e.Groups.forEach is not a function
    at Ct.setPublicDomainData (otBannerSdk.js:7)
    at Ct.<anonymous> (otBannerSdk.js:7)
    at otBannerSdk.js:7
    at Object.next (otBannerSdk.js:7)
    at otBannerSdk.js:7
    at new Promise (<anonymous>)
    at c (otBannerSdk.js:7)
    at Ct.initializeBannerVariables (otBannerSdk.js:7)
    at otBannerSdk.js:7
    at otBannerSdk.js:7
I think this is due to the data attributes in the script tag,
data-document-language and data-domain-script, as they aren't valid attributes in any of the namespaces I'm using and XHTML is strict about that sort of thing:
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    lang="en-US">
What I'm thinking is that XHTML doesn't like those data attributes, so the script is trying to run without them, and the console error is arising from a null value.
Is there any way around this? I know that JSF 2.2+ allow for some custom attribute options but I wasn't sure they applied to script tags specifically
It's my first time working on a JSF project so apologies if I've missed anything, thanks.
 
    