All nodes (Drupal 7) contain the following code:

<script type="text/javascript" src="http://localhost:8080/myfeodor.de/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://localhost:8080/myfeodor.de/misc/jquery.once.js?v=1.2"></script>
<script type="text/javascript" src="http://localhost:8080/myfeodor.de/misc/drupal.js?nxe6cr"></script>
<script type="text/javascript" src="http://localhost:8080/myfeodor.de/sites/default/files/languages/de_HizaMms-3Ux-y0M1w9o2_EvSFCBziqwcKzQq9_kzJ78.js?nxe6cr"></script>
<script type="text/javascript">
    jQuery.extend(Drupal.settings, {
        "basePath": "\/myfeodor.de\/",
        "pathPrefix": "",
        "ajaxPageState": {
            "theme": "my_garland",
            "theme_token": "WTVBB9vMIjxgWuVheFjYXjuvpo1TgahCH62PRBBFGrA",
                "js": {
                "misc\/jquery.js": 1,
                "misc\/jquery.once.js": 1,
                "misc\/drupal.js": 1,
                "public:\/\/languages\/de_HizaMms-3Ux-y0M1w9o2_EvSFCBziqwcKzQq9_kzJ78.js": 1
            "css": {
                "modules\/system\/system.base.css": 1,
                "modules\/system\/system.menus.css": 1,
                "modules\/system\/system.messages.css": 1,
                "modules\/system\/system.theme.css": 1,
                "modules\/comment\/comment.css": 1,
                "modules\/field\/theme\/field.css": 1,
                "modules\/node\/node.css": 1,
                "modules\/search\/search.css": 1,
                "modules\/user\/user.css": 1,
                "sites\/all\/themes\/my_garland\/style.css": 1,
                "sites\/all\/themes\/my_garland\/print.css": 1,
                "sites\/all\/themes\/my_garland\/fix-ie.css": 1

The file de_HizaMms-3Ux-y0M1w9o2_EvSFCBziqwcKzQq9_kzJ78.js contains an associative array where error messages are translated. But this appears not to be necessary since the page works also with scripting deactivated in the browser.

This is WAMP, but under Linux the same code appears.

This code is also present if one is only reading without being logged in. Is is possible to avoid this scripting?

Drupal 6 has been Javascript-clean for readers.

  • Please read this carefully: drupal.stackexchange.com/questions/14332/… and then maybe delete $scripts from your html.tpl.php, ideally in a Garland subtheme you have to create first, since hacking the core is no good idea.
    – leymannx
    Nov 15, 2015 at 22:11
  • Thanks for the reply. I did not find the post by google. html.tpl.php is only implemted in the core. Perhaps one would have to copy this file into the Garland subtheme folder. Deleting <?php print $scripts; ?> would then deactivate Javascript totally which means also in the backplane. Right? One workaround for this would be perhaps to use another theme for maintenance.
    – Feodor
    Nov 16, 2015 at 17:32

2 Answers 2


At drupal.org user Jaypan propsed to implement a new module (named e.g. killjs) which would have to implement hook_js_alter()

function killjs_js_alter(&$javascript) {
  // Insert code to check whether JS should be killed or not.
  $javascript = array();

This, however, would be very laborious for non-experts since it would be necessary to do a more or less complete analysis of the Drupal code base first. User leymannx proposed a solution which may be realized without developing a new module:

  • Javascript is deactivated only for a specific theme, here called custom_garland.
  • Copy file modules/system/html.tpl.php into the customized theme folder as /sites/all/themes/custom_garland/html.tpl.php.
  • In the copied file html.tpl.php delete the line <?php print $scripts; ?>.
  • Clear the drupal cache.
  • Select custom_garland as default theme.

Now for guests the page is clean of Javascript! In the backplane, Javascript is still active due to file maintenance-page.tpl.php. This means one can still adust the Garland/Bartik colors or drag blocks.

For me, the maintenance mode works with the above modified theme. Stefan Korn presented a refinement of this apporoach where JavaScript is fully activated for users which are logged in.


If you only want to delete the javascript for anonymous user you could easily go like that in html.tpl.php:

<?php if($logged_in == 1): ?>
  <?php print $scripts; ?>
<?php endif ?>  
  • This approach looks very good. But searching the complete D7 codebase I could not find any variable $is_loggedin. But in modules/user/user.module I found function user_is_logged_in(). So should one write <?php if(user_is_logged_in() == true): ?>instead of <?php if($is_loggedin == 1): ?>?
    – Feodor
    Nov 18, 2015 at 8:15
  • Sorry, it should read $logged_in. This is a global variable available in all templates. But you can also go via user_is_logged_in(). Nov 18, 2015 at 8:31
  • Yes, I could find $logged_in in the codebase. Appears to be correct. Thx.
    – Feodor
    Nov 18, 2015 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.