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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:02:44+00:00 2026-05-19T01:02:44+00:00

I recently noticed that some (not all) of my javascript and jQuery scripts wouldn’t

  • 0

I recently noticed that some (not all) of my javascript and jQuery scripts wouldn’t work unless I put the link for the .js files nearer towards the bottom of the page instead of the head area where I put my links for my .css files.

From what I understand, javascript can go in either places and it is recommended to not be put in the header as it slows down the page loading process as well. At the same time, if I put it in the body tag of the html file, it looks somewhat messy and was wondering what the best practice is for putting .js files in a cleanly place. Should I always put it at the very bottom right before the ending body tag? How do professional web developers handle this?

  • 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-05-19T01:02:44+00:00Added an answer on May 19, 2026 at 1:02 am

    If your scripts did not work unless you put them towards the bottom then you most probably started manipulating the DOM when the DOM wasn’t ready yet (or maybe you used document.write, but I doubt that this was the case). To solve this you need to start processing only when the DOM is ready. With jQuery you’ll need something like:

    $(function() {
        // DOM is ready here and you can safely manipulate it
    });
    

    Regarding how the positioning of the scripts affects performance I suggest you read those 3 articles from the guru of client side performance:

    • http://www.stevesouders.com/blog/2010/12/15/controljs-part-1/
    • http://www.stevesouders.com/blog/2010/12/15/controljs-part-2/
    • http://www.stevesouders.com/blog/2010/12/15/controljs-part-3/

    Asynchronous loading and delayed execution are very hot subjects right now. They allow you to cleanly define everything at the <head> but be very specific about how they get loaded and when they are excecuted.

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

Sidebar

Related Questions

Recently, I noticed some people mentioning that std::list::size() has a linear complexity. According to
I recently switched to Outlook 2007 and noticed that my VBA-macros won't work. I
Recently I noticed my application appears to be eating memory that never gets released.
We recently switched some of our sites from deflate to gzip and noticed a
I have recently noticed how interesting Visual Studio's macros are. I did not use
I just recently noticed Dictionary.TryGetValue(TKey key, out TValue value) and was curious as to
I've recently began using dTrace and have noticed just how awesome it is. Its
Background: Recently while looking at a structured text editor I noticed they used a
Recently, I started changing some of our applications to support MS SQL Server as
I've written (in JavaScript) an interactive read-eval-print-loop that is encapsulated within an object. However,

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.