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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:00:36+00:00 2026-05-18T12:00:36+00:00

I am building a public facing website and I am using a lot of

  • 0

I am building a public facing website and I am using a lot of jQuery and jQueryUI. What I have noticed is that most site on internet that use jQuery and jQueryUI don’t have code like this in their pages.

<script type="text/javascript">
  $(document).ready(function(){

    $("a").click(function(event){
      alert("Thanks for visiting!");
    });

    $( "input:submit" ).button();
  });
</script>

I know this is a simplistic example but most sites, for example SO have only one obfuscated js file included for all the pages. It doesn’t even seem like they use $(document).ready anywhere. On my current site it seems like I would need to include a js file for each page. My question is how is it suppose to be done and is there a best practice on how to use/include javascript in a page?

  • 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-18T12:00:36+00:00Added an answer on May 18, 2026 at 12:00 pm

    According to W3C you could put scripts almost anywhere: http://www.w3schools.com/js/js_whereto.asp

    So where should you put them?

    Ege is right to say that you should put them as far down the page as possible because it will enable the browser to load more in parallel up front before it gets to the ‘blocking’ scripts. See here for more detail: http://developer.yahoo.com/performance/rules.html#js_bottom

    Also, it is nearly always a good idea to put your scripts (and CSS) into external files so the browser can cache them tus saving the user from having to download them with the page each time.

    Personally, I always use a CDN for script frameworks such as jQuery and the like as they can deliver external resources quicker than you probably can. Also the likelyhood of the browser having already cached jQuery for another site from the same CDN is far more likely. More detail here: http://code.google.com/apis/libraries/devguide.html

    Finally, there’s nothing wrong with using $(document).ready, but just be aware that this could affect the site’s responsiveness and its pros may not outweight its cons. Again, more detail here: http://encosia.com/2010/08/18/dont-let-jquerys-document-ready-slow-you-down/

    Hope this helped.

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

Sidebar

Related Questions

I am building a site that will (obvisouly) have a front end public portion
I'm building a class library that will have some public & private methods. I
I'm building a site that uses tweets from Twitters public timeline. http://twitter.com/statuses/public_timeline.xml I don't
I'm building a public website which has its own domain name with pop/smtp mail
Let's say we are building some public service that grabs the setup of a
I am building a database that contains public, private(limited to internal) and confidential data
I have a web service that looks like this: public class TheService : System.Web.Services.WebService
I have MVC administration screens that I use to create/delete/edit and list data. Right
Say I'm building two applications: 1) A public website 2) A service The website
I'm building a php framework that redirects all traffic to ROOT/public/index.php and then puts

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.