How to include a script from an external source?

Created on 22 August 2016, about 8 years ago
Updated 18 July 2023, over 1 year ago

Example, I have to put this on some pages (it's a Support chat by Userlike):
<script type="text/javascript" src="//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/4617781667baec8520773c9c3309d3ddda46e0683c6347e07b7a63a21f2efbe5.js"></script>

The module always wraps around the script tag, so how can I do (prevent) that?

Wouldn't it be possible to have this nice little feature where with a checkbox I can
"Let me add the script tags myself"?

Thanks :)

💬 Support request
Status

Active

Version

2.0

Component

Documentation

Created by

🇮🇹Italy kopeboy Milan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom robcarr Perthshire, Scotland

    nironan's suggestion at #3 has worked really well for me, although worth noting that the JS has to be executed in the footer for the document.body.appendChild(scriptTag); to work.

    I had to add Plausible to a D7 site (which only has a D8+ module), couldn't add the recommended snippet to the theme, so used the following JS executed inline in the footer (following provided to those landing here via a search listing):

    var scriptTag = document.createElement('SCRIPT');
    scriptTag.src = 'https://plausible.io/js/script.js';
    scriptTag.dataset.domain = "MY DOMAIN";
    scriptTag.async = true;
    scriptTag.defer = true;
    document.body.appendChild(scriptTag);
    
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.71.5 2024