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 101153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:42:59+00:00 2026-05-11T00:42:59+00:00

I would like to execute the jQuery $(document).ready() in a drupal site. While i

  • 0

I would like to execute the jQuery $(document).ready() in a drupal site. While i know that i can just stick it in the index page , this is really messy and a hack.

What i want to know is where is the correct location to put this, it would also need to be theme specific as i dont want all themes to use it.

Thanks in advance for the help.


Sweet success , thanks both of you for the help , i just have one last amend to this question. Now that i have got this far , i need to execute the jQuery code to update the document , can i use the context to modify the document ?

  • 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. 2026-05-11T00:43:00+00:00Added an answer on May 11, 2026 at 12:43 am

    VonC adequately answered the ‘how’ part of the question, so I’ll focus on the ‘where’ part.

    If the script is theme-specific, then the natural place to put the script file is in your theme. The problem is that by the time Drupal gets to the theme, the $scripts variable has already been ‘rendered’ (in Drupal parlance) into HTML. To add a script in the theme layer, you need to add the script and rebuild the $scripts variable.

    Assuming you’re using Drupal 6, this would go in your theme_preprocess_page() function:

    drupal_add_js(drupal_get_path('theme', 'theme_name') .'/example.js', 'theme'); $variables['scripts'] = drupal_get_js(); 

    Just change the second argument of drupal_get_path() to reflect the name of your theme, then change the name of the script file from example.js to whatever you’ve named your script.

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

Sidebar

Ask A Question

Stats

  • Questions 100k
  • Answers 100k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Function Points and WBS are two different, but related items.… May 11, 2026 at 7:51 pm
  • Editorial Team
    Editorial Team added an answer Try using System.Web.HttpContext.Current. May 11, 2026 at 7:51 pm
  • Editorial Team
    Editorial Team added an answer You need to mock or stub the [] operator on… May 11, 2026 at 7:51 pm

Related Questions

What I'd like to know is if there is a nice way to queue
Scenario: I have a partial view that is used in several places across my
I was going to use jQuery to clone the input field when I click
The following code executes properly when the data key has no data to send,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.