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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:20:32+00:00 2026-05-31T15:20:32+00:00

I guess this is a pretty beginner question, I know that generally you will

  • 0

I guess this is a pretty beginner question,

I know that generally you will have a ‘myCustomScript.js’ file on a site. But if you have lots of Javascript that is only applicable to one page or another does it make sense at all to have .. ?

sitewide.js
pageX.js
pageY.js

I just haven’t really seen this before, and I wonder why (maybe because the amount of “page-specific” javascript would be negligible in most cases?). But I have 2 big chunks that are only being used on their respective pages and it seems to make sense in the interest of cutting down pageload to split them up. Bad idea?

//// EDIT /////

I think I have just seen another response that gives me the answer. “In small amounts it really doesn’t matter”.

So how much .js code is worth one extra request? If I have ‘x’ lines of code in “thisPageOnly.js’ .. how many lines would that have to be to justify an extra request?

  • 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-31T15:20:34+00:00Added an answer on May 31, 2026 at 3:20 pm

    Yes, that makes sense. Eventually any big web application will have page-specific JavaScript.

    To make easier maintanence of the java script files and pages, you can name-space your functions/classes that deal with siteX to be prefixed with siteX. Remember to put the includes for site-specific js at the bottom of the html-output.

    A reason for why you might not have seen it is that when you name-space your js you could add it all in one js file and obfuscate or minimize that. If you have 10-20 page-specific js files, you will make 10-20 requests which is not that good, so you have page-specific js content but including it once. And the way to do that is to name-space correctly for each page.

    Have you learned about prototypes and namespacing yet?

    Like this:

    var yourPageNameSpace = {
        func1: function () {},
        func2: function() {}
    }
    

    then you do yourPageNameSpace.func1()

    So in short. Yes that is okay for one or two pages, but not for each and every page you have. Consider namespaces in that situation.

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

Sidebar

Related Questions

I guess this is kind of an odd question but I have tried setting
I guess this question will sound familiar, but I am yet another programmer baffled
I guess this question of mine is pretty basic but since Ive never done
Ok, I guess this is a pretty easy solution question. Everything that is shown
I guess this is a pretty newbie question, but I've spent only 2 weeks
I guess this is a pretty rare question, but it would be pretty cool
I guess this is simple, but i couldnot figure it out. i have a
I have a HashMap (although I guess this question applies to other collections) of
I know this is a duplicate kind of question. I have worked with ASP.Net
Guess this is a pretty simple problem. I've got a regex and php that

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.