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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:09:51+00:00 2026-05-15T00:09:51+00:00

Looked around, couldn’t find this specific question discussed. Pretty sure the difference is negligible,

  • 0

Looked around, couldn’t find this specific question discussed. Pretty sure the difference is negligible, just curious as to your thoughts.

Scenario: All Javascript that doesn’t need to be loaded before page render has been placed just before the closing </body> tag. Are there any benefits or detriments to lazy loading these instead through some Javascript code in the head that executes when the DOM load/ready event is fired? Let’s say that this only concerns downloading one entire .js file full of functions and not lazy loading several individual files as needed upon usage.

Hope that’s clear, thanks.

  • 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-15T00:09:52+00:00Added an answer on May 15, 2026 at 12:09 am

    There is a big difference, in my opinion.

    When you inline the JS at the bottom of the <body> tag, you’re forcing the page to load those <script>s synchronously (must happen now) and sequentially (in a row), so you’re slowing down the page a bit, as you must wait for those HTTP calls to finish and the JS engine to interpret your scripts. If you’re putting lots of JS stacked up together at the bottom of the page, you could be wasting the user’s time with network queueing (in older browsers only 2 connections per host at a time), as the scripts may depend on each other, so they must be downloaded in order.

    If you want your DOM to be ready faster (usually what most wait on to do any event handling and animation), you must reduce the size of the scripts you need to as little as possible as well as parallelize them.

    For instance, YUI3 has a small dependency resolution and downloading script that you must load sequentially in the page (see YUI3’s seed.js). After that, you go through the page and gather the dependencies and make 1 asynchronous and pipelined call to their CDN (or your own servers) to get a big ball of JS. After the JS ball is returned, your scripts execute the callbacks you’ve supplied. Here’s the general pattern:

    <script src="seed.js"></script>
    <script>
    
        YUI().use('module', function(Y) {
            // done when the ball returns and is interpretted
        });
    
    </script>
    

    I’m not a particularly big fan of putting your scripts into 1 big ball (because if 1 dependency changes, you must download and interpret the whole thing over again!), but I am a fan of pipe-lining (combining scripts) and the event-based model.


    When you do allow for asynchronous, event-based loading, you get better performance, but perhaps not perceived performance (though this can be counteracted).

    For instance, parts of the page may not load for a second or two, and hence look different (if you’re using JS to affect the page style, which I don’t advise) or not be ready for user interaction until you (or those hosting your site) return your scripts.

    Additionally, you must do some work to ensure your <script>s have the right dependencies to be able to execute properly. For instance, if you don’t have jQuery or Prototype, you can’t successfully call:

    <script>
    
        $(function () {
            /* do something */
        });
    
    </script>
    

    or

    <script>
    
        document.observe('dom:loaded', function {
            /* do something */
        });
    
    </script>
    

    as the interpretter will say something like “Variable $ undefined”. This can happen even if you’ve added both <script>s to the DOM at the same time, as I’d bet jQuery or Prototype are bigger than you’re application’s JS (so the request for the data takes longer). Either way, without some type of limiting, you’re leaving this up to chance.


    So, the choice is really up to you. If you can properly segment your dependencies – i.e. put the stuff you need up front and lazily load the other stuff later, it’ll result in faster overall time until you hit the DOM being ready.

    However, if you use a monolithic library like jQuery or the user expects to be able to see something involving JS animation or style right away, inlining might be better for you.

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

Sidebar

Related Questions

I looked around on Google for this, but couldn't find anything. I want to
I have looked around on the Internet trying to answer this question. It seems
I looked around and couldn't find one. Is there an equivalent of Log4X for
I've already looked around but couldn't find the exact solution/problem I'm having right now.
Sorry, I'm new to SVN and I looked around a little for this. How
I looked at SQL Server dateformat codes but I couldn't find dd.mm.yyyy hh:mm format
Possible Duplicate: Learning to write a compiler I looked around trying to find out
I looked in the Rails docs under inflector and found this message... Module deprecated
So I've looked at this use of the freebase API and I was really
I have looked around for the past year to put tide predictions on a

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.