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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:59:11+00:00 2026-05-12T13:59:11+00:00

Walter Rumsby provided a great answer to Where to place JavaScript in an HTML

  • 0

Walter Rumsby provided a great answer to Where to place JavaScript in an HTML file. He references the work done by the Yahoo Exceptional Performance team and their recommendation to place scripts at the bottom of the page. Which is a hard and fast rule that I’ve been following for quite sometime now. In the same thread Levi Rosol pointed out “the best place for it [JavaScript] is just before you need it an no sooner.” That is the predicament that I now find myself in.

I’ve added my reference to jQuery at the end of my page but have run into an issue with how to structure a user control that I’d like to add client side functionality to. Specifically, I am having a hard time working out the best way to accommodate dependencies. The user control has a span tag containing a numeric value that I’d like to update based on the number of check boxes the user has checked in the user control. I am using jQuery to find the span tag and update its text property.

Unfortunately, unless my reference to jQuery appears prior to the user control I receive JavaScript errors. This makes sense because the control is referencing functions that have not yet been added. I can think of several solutions to the issue but am looking for a best practice option.

  1. Placing a reference to the jQuery library inside of the user control.
    • Downside: if the user control was placed into a repeater multiple references to the jQuery library would be made.
  2. Put no JavaScript in the user control and write all code to update the span tag for the user control in the containing page.
    • Downside: I’d end up with the same code in multiple places creating a potential maintenance nightmare.
  3. Place the jQuery reference in the head section of the page.
    • Downside: I’ve violated the recommendation to place scripts at the bottom of the page and have created an unusable user control if the page does not include a reference to jQuery.

Those are the options and downsides I came up with when thinking about solutions to this problem. I am certainly open to suggestions for better solutions and barring none looking for a recommendation of which of the three I should choose.

  • 1 1 Answer
  • 1 View
  • 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-12T13:59:11+00:00Added an answer on May 12, 2026 at 1:59 pm

    Another option would be to dynamically generate the script reference by registering a startup script from your usercontrol that wrote a script reference to the document head.

    The javascript function could check for an existing jQuery reference, and if none was found, write the reference out. This would solve the multiple references. A basic example was discussed in this thread.

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

Sidebar

Related Questions

I can't properly set color of water with google maps api v3. My RGB
I frequently do this sort of thing: class Person(object): def greet(self): print Hello class
I need to render the Girobank tear-off slips that are commonly found on UK
I have a map that is cut up into a number of regions by
I see that there are several ways to distort an image. like...Circle, Diffuse, Marble,
I would like to find a Google Maps API v3 friendly way to add
I have 2 tables in a database. I use following query: Select U.id, U.ad,
I created a program in VS2008 and windows 7 32bit. To get the program
Ok, this may seem like a dupe question, but if you bear with me
I am trying to panTo an area on a map on click. The script

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.