Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8467819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:45:19+00:00 2026-06-10T15:45:19+00:00

In drupal 6, I’ve written a module that outputs some html which I am

  • 0

In drupal 6, I’ve written a module that outputs some html which I am displaying in a block using hook_block.

There is a js file that I want to load only when that block loads so I am drupal_add_js() inside hook_block.

It is all working except for this problem: when you refresh the page (regardless of whether you clear caches at the same time), often an old version of the script gets loaded. Newer and older versions turn up on a seemingly random basis.

What can I do to ensure that the correct version is loaded? Thanks.

Edit: One of the stylesheets that I’m loading via the theme’s .info file is doing the same thing – random versions of it are loading. So it looks like a general problem not module or block related.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:45:20+00:00Added an answer on June 10, 2026 at 3:45 pm

    Until youre satisfied with the javascript file, so that it may be locked down and used in cache, use the ‘defer’ and ‘cache’ arguments to drupal_add_js.

    In admin > > performance you will find directives that includes js and css – if they’re deactivated, then one request is made per file added by drupal_add_*. If for instance js has preprocess set true, then all .info javascripts and scripts added by drupal_add_js will get sutured together into: one optimized deeply cached script

    < 7.0

    drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE, $preprocess = TRUE)
    

    7.0 >

    drupal_add_js($data = NULL, $options = NULL)
    

    In your situation, if youre developing a script or need to push one fresh on every load, under all circumstances use false under $cacheand $preprocess, so loading ‘main.js’ looks like:

    drupal_add_js(base_path() . '/sites/default/files/myjs/main.js', 
         'core', 
         'header', 
         false, 
         false, 
         false
    );
    

    In v7+ func argv[1-X] would simply be put together in an associative array as $options, see API

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Drupal has some built in views that work without Views contrib module. We even
Drupal 7 has the field group module which contains a horizontal_tab.js file. Inside this
Drupal 6.x I have this module that manages four different content types. For that
Using Drupal, the theme has a background color assigned to the <HTML> element. I'm
Using Drupal on a project which I made custom node types in using the
On Drupal 6, I used to have a custom PHP block which accessed arg(0),
Using Drupal 7, using views i have created a related 'videos' block for various
Drupal Aggregator core module is a useful one but suffers many problems. There are
Drupal is very much a Do Everything CMS. There are modules that allow you
The Drupal 6 menu module hides links to content that the current user does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.