Option to place script in <head>

Created on 26 June 2023, over 1 year ago
Updated 7 September 2023, over 1 year ago

Problem/Motivation

Love the module, very handy! Lately we have had a few requests to place the tag inside <head>. We usually just go with this anyway and it always works fine at the top of the <body> but I wondered if this is not a common requirement? Dealing with one now where they are insisting it go in <head> so will have to hard coded it.

Does anyone else think this would be a useful feature?

✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia pameeela

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

Comments & Activities

  • Issue created by @pameeela
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Seems reasonable to me

  • First commit to issue fork.
  • πŸ‡³πŸ‡ΏNew Zealand heathergaye

    I've had a go at this now.

    My main hangup is that the scripts for the page top and bottom need script tags, but scripts in the head are added as attachments, and they must exclude script tags. Don't know the best way to handle this. I put a comment in the snippet description; guidance for the user may be sufficient. We could strip tags out on saving and/or validate & error out, but I don't know how many varying use cases we might need to cover.

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    For a client who was behind a WAF and couldn't submit POST entries with script tags, we wrote a module to split the textarea into three fields (html, css, js) and then reconstituted that into separate tags.

    Perhaps that's an option here?

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Took a look at the MR, that looks reasonable to me.

    Perhaps we could add validation to the form to check for <script> when the position is head?

  • πŸ‡³πŸ‡ΏNew Zealand heathergaye

    I've now added validation to check for script tags if head position is specified (and fixed my commit workflow on the fork. Everything is on the issue branch).

  • Status changed to Needs review over 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia pameeela

    I know Lee is away all month but maybe @acbramley or @dpi could give us a review :)

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    4 fail
  • @pameeela opened merge request.
  • πŸ‡¦πŸ‡ΊAustralia pameeela

    Just realised there was no MR for this so I created one.

  • Status changed to Needs work over 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Looking good, left a couple of minor comments on the MR

    It looks like we have a failing test too?

Production build 0.71.5 2024