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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:42:43+00:00 2026-06-05T18:42:43+00:00

I am using a master page, and JQuery is referenced in some, but not

  • 0

I am using a master page, and JQuery is referenced in some, but not all pages. I am adding some user controls which use client side JQuery, and so need to include the reference to the jQuery library in the pages using them.

There are obviously many ways to achieve this but I was wondering thoughts on relative merits disadvantages of the following techniques (or if indeed a better technique exists):

  1. Add a script element (by creating an HTMLgenericControl with the relevant attributes) to the header controlCollection – cons -> several script elements pointing to the same file may be served to the client, if the page and a few user controls all use jquery. Is this really a disadvantage? will the browser try and download several copies?

  2. Add a masterPage boolean property jQueryLib & add the script element as above only if it has not already been added. Disadvantage – in the case of masterpages, I am not able to set the properties in the ASP, as I can with user controls. Thus all pages will need more code-behind rather than a simple <%@ Page jQueryLib=”true”>

  3. Use some fairly simple client side javascript to load jQuery and run associated script after the library is loaded if jQuery===’undefined’. Cons – the script tags pointing to the javascript utility function for doing this will still be in the header multiple times if a number of user controls are used on the one page. As an advantage however, this file is much, much smaller than the jQuery library.

  4. Just put the script reference in the master page, even though only those logged in as administrators require any jquery functionality.

As always – thank you very much for your thoughts an apologies for my amateurish knowledge of all things html and asp.

  • 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-05T18:42:46+00:00Added an answer on June 5, 2026 at 6:42 pm

    You could only add jQuery to the MasterPage for administrators using something like the following:

    Serverside:

    protected bool administrator { get { return true; } }
    

    Javascript:

    function pageLoad(sender, args) {
        var administrator = "<%= administrator %>".toLowerCase() == "true" ? true : false;
    
        if(administrator == true)
            loadJQuery();
    }
    
    function loadJQuery(){
        var scriptTag = document.createElement("script");
        var filePath = "jquery.js";
    
        scriptTag.onload = function( loadEvent ){
            // This function runs when jquery is loaded
        }
    
        scriptTag.type = "text/javascript";
        scriptTag.src = filePath;
        document.getElementsByTagName("head")[0].appendChild(scriptTag);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using nested master pages, which may or may not cause the problem
in my application i am using master page and child pages. my requirement is
I'm using Umbraco and every page is a master page which is a sub
We are using Sharepoint 2007 In which on master page we have Asp Image
Good day everyone, I am building a page in ASP.NET, and using Master Pages
I have a web app using master page and content pages (see the attached
I'm using jquery to validate an asp.net form (content within a master page). The
In my ASP.Net app, which is javascript and jQuery heavy, but also uses master
I am creating Menu in the master page using JQuery. i am passing the
I have a view using a master page that contains some javascript that needs

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.