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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:34:21+00:00 2026-05-15T20:34:21+00:00

It is said that Javascript code should be all placed at the end of

  • 0

It is said that Javascript code should be all placed at the end of HTML file, so that the page content is shown first, for the user to see something (so that the user is satisfied to see something instead of waiting another 12 seconds, for example).

But to better encapsulation of the HTML and match Javascript code, such as an “Image Carousel”, then usually the HTML and Javascript is placed in one single file, so there are Javascript code blocks all intermixed with HTML code throughout the final HTML file.

But what if all these Javascript code blocks use jQuery’s $(document).ready(function() { ... }) to perform the task, then won’t the page display be very fast as well? I think not as fast as when the Javascript is actually placed at the end of the HTML file, but close enough, because it merely adds a function to the ready event queue.

  • 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-15T20:34:22+00:00Added an answer on May 15, 2026 at 8:34 pm

    I think the point is to place the js at the bottom of the page (usually just inside the closing </body> tag) so that the content of the page is displayed while the js is downloading.

    If you have your jQuery code spread out throughout the HTML in separate .ready() calls, then no matter what, it won’t run until the <body> has fully loaded. So the question would be how much javascript do you have in the HTML?

    If there’s quite a bit, then it will slow down the display of any content that comes after each script. If it is a relatively small amount of code, then it won’t likely make much noticeable difference.

    If it is really important to you to have the page’s content displayed as soon as possible, then place all scripts after the content.

    I personally wouldn’t mix javascript with HTML just for the sake of association. You could have unexpected results if you start removing/appending content that happens to include a script. I’d rather use appropriately named classes and IDs, as well as lots of code comments.

    Also keep in mind that those .ready() calls won’t work until jQuery has loaded, which would mean that it would need to be at the top of the page, or at least before your first call.

    So again it gets back to the question of which is more important to you. If you want the content visible as quickly as possible, place all js at the bottom. If you want your method of intermixing js and HTML, you’ll have some delay in displaying the page.

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

Sidebar

Related Questions

Somebody said that when your PHP code and application use global variables then it
Doctrine2 docs said that soft-delete behavior should be better implemented as a State pattern
On various places they said that you should use @ManagedProperty to get a request
I have JavaScript code that calls a method in ASP.NET. Basically, I have a
I would like a simple JavaScript code that will allow me to hide a
I was often said that rule : HTML is static ; in other words
It is said that When an interrupt is sent by the PIC, the PIC
It is often said that in C++11 it is sane to return std::vector by
It is said that fork system call creates a clone of the calling process,
In manual it said that InnoDB has row-level locking, so why if I select

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.