1

I've been tasked with removing 'drupal' from front end source code and I've managed to remove most by modifying templates and using theme hooks, but I'm struggling to remove it from a <script> tag on the bottom of the page:

<script type="application/json" data-drupal-selector="drupal-settings-json">

I know that this comes from core/lib/Drupal/Core/Asset/JsCollectionRenderer, but I don't know how to modify it without creating a patch or overriding the class (which I want to avoid).

Is there a preprocess hook I can use to remove it? I have not found one that contains that text.

  • Do you want to remove it entirely? Because I believe that's an important tag for functionality. – Matt Mar 12 at 14:28
  • @Matt I just want to remove the attribute: data-drupal-selector="drupal-settings-json" – user1205853 Mar 12 at 14:39
  • I believe that attribute is necessary and used as a selector – Matt Mar 12 at 14:42
  • For example it's used by the drupalSeettingsLoader.es6.js here: const settingsElement = document.querySelector( 'head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]', ); – Matt Mar 12 at 14:43
  • @Matt Hmm. I suspected that may be the case. Is there any way I can hide it? The requirement is that they don't want anyone to know the site is using Drupal by viewing the HTML source code. – user1205853 Mar 12 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.