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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:23:25+00:00 2026-06-04T08:23:25+00:00

I am confused about which JavaScript should be included where? For instance: Where should

  • 0

I am confused about which JavaScript should be included where?

For instance:

  • Where should one include the jQuery libraries? In the <head> or before the closing </body> element?

  • If the JavaScript is defined at the bottom in the <body>, can it be used inline in the body?

  • If it blocks parallel downloads, then why is it never said to include your CSS at the bottom?

  • 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-04T08:23:27+00:00Added an answer on June 4, 2026 at 8:23 am

    The Place of the <script> Element

    The script elements block progressive page downloads.
    Browsers download several components at a time, but when they encounter an external script, they stop further downloads until the script file is downloaded, parsed, and executed.
    This hurts the overall page time, especially if it happens several times during a page load.
    To minimize the blocking effect, you can place the script element toward the end of
    the page, right before the closing tag.
    This way there will be no other resources for the script to block.
    The rest of the page components will be downloaded and already engaging the user.
    The worst antipattern is to use separate files in the head of the document:

    <!doctype html>
    <html>
    <head>
        <title>My App</title>
        <!-- ANTIPATTERN -->
        <script src="jquery.js"></script>
        <script src="jquery.quickselect.js"></script>
        <script src="jquery.lightbox.js"></script>
        <script src="myapp.js"></script>
    </head>
    <body>
    ...
    </body>
    </html>
    

    A better option is to combine all the files:

    <!doctype html>
    <html>
    <head>
        <title>My App</title>
        <script src="all_20100426.js"></script>
    </head>
    <body>
        ...
    </body>
    </html>
    

    And the best option is to put the combined script at the very end of the page:

    <!doctype html>
    <html>
    <head>
        <title>My App</title>
    </head>
    <body>
        ...
        <script src="all_20100426.js"></script>
    </body>
    

    “JavaScript Patterns, by Stoyan Stefanov
    (O’Reilly). Copyright 2010 Yahoo!, Inc., 9780596806750.”

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

Sidebar

Related Questions

I am confused about js file of jQuery which one i have downloaded just
I am confused about which collection type that I should return from my public
I'm a little confused about which jQuery method and/or selectors to use when trying
I'm a little bit confused about which method to use : 1- using Jquery
I am a bit confused about this. If you're building a distributed application, which
I get a compile error, which I'm slightly confused about. This is on VS2003.
I'm trying to complete an exercise for a JavaScript class and I'm confused about
I've recently come across a situation where I've been a bit confused about which
After read the google map javascript v3 api,I found I am confused about some
I am using SQL Server 2008. I am confused about which account will be

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.