Adding a script tag just before </body>

  • Charlie

    26 days ago

    I'm trying to load a 3rd party script that needs to be in the body but keeps coming back with the error:
    Code found in the page <head>. Please place code directly before the </body>

    I've tried it as a component, setting script type to module, as the last element on the page but nothing seems to be working. The code snippet is pretty basic - example below:

    <script type="text/javascript">
    var vglnk = {key: '454b80f1502c'};
    (function(d, t) {var s = d.createElement(t);
    s.type = 'text/javascript';s.async = true;
    s.src = '//cdn.viglink.com/api/vglnk.js';
    var r = d.getElementsByTagName(t)[0];
    r.parentNode.insertBefore(s, r);
    }(document, 'script'));
    </script>

    Any advice on how to get around this error?
    🥲1

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.