I'm not sure if this is a bug on the module's part but there is a work around. The issue is that the Javascript being added via the hook_page_attachments_alter is being truncated/escaped. I've managed to fix this myself by adding code of the form

use Drupal\Core\Render\Markup;

...


$attachments['#attached']['html_head'][$i] = [
     [
       '#type'  => 'html_tag',
       '#tag'   => $script_tag,
       '#value' => Markup::create($value),
     ],
        'header-and-footer-scripts-' . $i,
    ];

And that appears to allow the script to pass through and function. There appears to be a support request in the Issue queue for D8 core that I believe is related to this problem.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

edward.radau created an issue. See original summary.

akbuje’s picture

I found your fix useful in my usecase @edvard.radau, thank you.

This case seems to duplicate two other issues though, which I have updated the case to include.

akbuje’s picture

Since I am using the change edward.radau has made, I have made his change into a patch to be reviewed for later use, if others find it useful.

akbuje’s picture

Status: Active » Needs review
dhanlal’s picture

Assigned: Unassigned » dhanlal

this patch not tested that why i update the this issue

dhanlal’s picture

dhanlal’s picture

dhanlal’s picture

Assigned: dhanlal » Unassigned
gisle’s picture

Patch in #6 by dhanlal in #6 is identical to the one submitted by akbuje in #3.

Plagiarism is just as bad as spam. Please take into account when assigning credit.

Jesmaster’s picture

The original patch missed a few spots, here's an updated version.

Nitesh Sethia’s picture

Updated the patch as per the different comments and the coding standards.

sasiddiqui’s picture

This issue was fixed in v3.0.0.

sasiddiqui’s picture

Assigned: Unassigned » sasiddiqui
Status: Needs review » Fixed
sasiddiqui’s picture

Status: Fixed » Closed (fixed)