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

  • Home
  • SEARCH
  • 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 9123985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:28:11+00:00 2026-06-17T06:28:11+00:00

I have about 40 lines of code that’s currently wrapped in doc.ready in the

  • 0

I have about 40 lines of code that’s currently wrapped in doc.ready in the head of my page. It’s all UI related stuff that will be used on every page of the website. Stuff like: scroll back to top button, fixed header background goes darker once scroll past certain height, .load to load html into a div container, etc…

Since the js will be used on every page of the website, what’s the best practice? Should I leave it as is and just move it to the footer of my page?

Or should I still create a default.js file that loads it in? Fairly new at this so any help is appreciated. thanks

  • 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-17T06:28:12+00:00Added an answer on June 17, 2026 at 6:28 am

    If you’re using the same script on multiple pages, then yes, it probably makes sense to put it in a separate .js file and reference it from each page (I do that anyway, even if only using the JavaScript on one page). And yes, if you control where the <script> tags are, there’s rarely any reason to use ready, just put the <script> tags at the bottom, just before the closing </body> tag. References for that last:

    • Google on when DOM elements are available
    • YUI Best Practices for Speeding Up Your Website
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have about 4000 lines of code that I need to re-style. I'm not
I have about 9 lines of code that will be the same in many
I have a few lines of code that should make a report about the
In the example I'm thinking of I have about 4 lines of code that
I have a mildly large function (about 80 lines of code without comments) that
I have a method that's about ten lines of code. I want to create
I have about 2000 lines of javascript code for my application. A lot of
I have a file of about 19500+ lines of code. I am doing work
I have been wondering about the following lines of code [self performSelector:@selector(myMethod) withObject:self afterDelay:1.0];
I have a data source with about 2000 lines that look like the following:

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.