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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:16:50+00:00 2026-05-27T15:16:50+00:00

Question If you use a single javascript file to hold all scripts, where do

  • 0

Question

If you use a single javascript file to hold all scripts, where do you put scripts that are for just one page?

Background

This may be a matter of opinion or “best practice” but I’m interested in others’ opinions:

I’m using the html5 Boilerplate on a project. They recommend you place all javascript in a single file script.js for speed and consistency. Seems reasonable.

However, I have a bit of geolocation script that’s only relevant to a single page, and not others. Should I break convention and just put this script on the page below my calls to the javascript libraries it depends on? Just put calls to the relevant functions (located in the script.js) file, below the links to the libraries they depend on?

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-05-27T15:16:51+00:00Added an answer on May 27, 2026 at 3:16 pm

    The good folks at html5 boilerplate recommend putting all of your javascript in script.js so that the browser will only have to load that one file (along with the others that h5bp uses) and to allow caching of that file.

    The idea is not to get caught up in the “recommended” way, and to think about things related to your own applications.

    • This geolocation file is only going to be used on this one page, right? It will never be used anywhere else.
    • The script.js file will be used on multiple pages.

    Well, then it wouldn’t make sense to put a “whole script” that will only be needed on one page in the script.js file. You should make the file external and call it separately on the page that it is needed. This will keep you from bloating the script.js file for functionality that may never get used by that user.

    However, if your “whole script” for the geolocation functionality is pretty small, then include it in script.js. If it doesn’t add to the speed of the download for that file, then it makes sense to include it there.

    The gist of all of this is, What is the best trade off for my application?

    These things we know to be true:

    • cached js files are good
    • fewer files to download are good
    • smaller files to download are good
    • maintenance is important

    Once you think of these things in terms of your application, the decision making becomes a bit easier. And remember, decisions that trade off milliseconds are not going to make much of a difference in your user’s “perception” of how fast your page is.

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

Sidebar

Related Questions

Just found this out, so i am answering my own question :) Use a
Since I use jQuery 1.3+ all except one timed test is using that. The
Similar, but different to this question : I use highlight occurrences a lot, but
The solution to this question suggested the use of John Resig's class implementation. This
The answer to another SO question was to use this SQL query: SELECT o.Id,
I'd like to use jQuery to grab all of the css file references from
I'm working on a program that uses HTML/CSS/Javascript/JQuery for its user interface. One of
I need a JavaScript function that goes through all of the elements of a
I am trying to use Javascript to transform part of a XML file to
Why is it that this works: http://jsfiddle.net/w82W8/1/ But this doesn't?: http://jsfiddle.net/w82W8/2/ This question may

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.