For a GDPR solution, I need to insert a script tag right after the opening <head> tag.
Is there a simple way to achieve that?
Building a component only allows me to insert it before the closing </head> tag.
The discussion revolves around inserting a script tag immediately after the opening <head> tag for a GDPR solution. Terrapop asks for a way to achieve this, noting that components only allow insertion before the closing </head> tag. IAmGav suggests using the theme CSS section, but Terrapop clarifies that the CSS field doesn’t accept script tags. Johani explains that the browser’s behavior is unaffected by the script’s position within the <head>, as execution order is not critical in this case, and the <head> tag is not meant for user content. They recommend adding the script before </head>, whitelisting the script source in CSP, and seeking further help if needed.
For a GDPR solution, I need to insert a script tag right after the opening <head> tag.
Is there a simple way to achieve that?
Building a component only allows me to insert it before the closing </head> tag.
The CSS field does not accept a <script type="text/javascript" src="https://app.xxxx.ai/script/xxx.js"></script> tag.
The browser doesn’t really care whether the script tag is added right after the opening <head> tag or right before the closing </head> tag. It will load it anyway and the result would be the same. The only thing that this affects is execution order (which doesn’t really matter in your case).
Further, your users also wouldn’t care about that since the <head> tag is not supposed to contain any user content (text, images, etc…) and is to set display: none in all browsers.
Please try to add your script tag to the </head> tab in your component and then whitelist the source of that script in CSP. If you run into any problems related to that, we can help ![]()