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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:08:41+00:00 2026-05-13T22:08:41+00:00

I am working on a medium size web site that has plenty of custom

  • 0

I am working on a medium size web site that has plenty of custom JavaScript written for it.

At present all the script is stored in seperate JS files for each area of functionality. These are then minified and combined into a single, large JS file during our build process.

For each page, the relevant JavaScript is usually executed based on the presence of an element with a particular class on the page. For example:

$(document).ready(function()
{
    var foo = $("div.dostufftome")
    if(foo)
    {
         // dostuff
    }
}

I’m concerned that this approach seems a little fragile, and also potentially quite slow.

The only other alternative I can see is to put the ‘activation’ code inline in the HTML in a CData section, with the bulk of the code in the attached JS file.

Grateful for any advice.

  • 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-13T22:08:42+00:00Added an answer on May 13, 2026 at 10:08 pm

    If you’re concerned about performance, it’s better to trigger behavior off of elements with “id” values. In my experience, unless there are many hundreds of such checks that your code needs to make, there’s no noticeable performance drag.

    You can possibly help even more by having more than one level of check. Give some pages with relatively unique needs a special class on the body tag, and then you can nest a bunch of tests within a test for that class. That way, pages that can be ruled out for some Javascript functionality will only require a single check.

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

Sidebar

Related Questions

I’m working in a development company, which develops small to medium size web based
I'm working on a medium-size project using JBoss Developer Studio (based on Eclipse ).
I'm working to create a simple Python script that will ultimately tell you how
I'm currently maintaining a small-medium sized java web application (using only plain JSPs/Servlets) that
I am working on a responsive site that with the aid of twitter bootstrap,
I have a medium size legacy php application with almost no javascript integration. I've
I'm currently working on a medium-sized web project, and I've ran into a problem.
I am working on a web application where images has to be scaled dynamically
I'm working on creating basic password security on a medium size PHP CodeIgniter website.
There is a medium size database application that needs to be built featuring a

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.