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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:11:36+00:00 2026-05-17T23:11:36+00:00

I am working with some legacy HTML/JS code, where I need to attach to

  • 0

I am working with some legacy HTML/JS code, where I need to attach to the load event.

The script I am working with is outside of the <head> tags.

Is listening to the load event unreliable when attaching the event listening outside of the head?

i.e.
Is it somehow possible that the page already loads and ignores my event listener?

In my testing the event listener is fired fine, but I’m ensure if this is the case all the time.

btw.
Due to the legacy nature I need to avoid using jQuery (an unhappy day).

  • 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-17T23:11:36+00:00Added an answer on May 17, 2026 at 11:11 pm

    Is listening to the load event unreliable when attaching the event listening outside of the head

    No, not if you’re literally talking about window.onload. window.onload happens very, very late in the process, after the entire HTML has been parsed (and also after any external resources like images and stylesheets and such have been completely loaded). It should be fine.

    Somewhat off-topic, but you can get an earlier reliable call if you like even without using jQuery. Just put this just before your closing </body> tag:

    <script type='text/javascript'>
        myLoadFunction();
    </script>
    </body>
    

    At that point, the DOM is reliably available, but the call happens a lot earlier than window.onload (depending on the size of your external resources, possibly even seconds earlier). Google’s JavaScript experts argue against the need for a jQuery-style “ready” event (see the link above) for this very reason. Some “unobtrusive JavaScript” folks don’t like it (although to me it’s not substantially different from putting a script tag in the head, provided the function is standardized across your app; it’s not like sprinkling onclick attributes all over the place), but it sounds like that ship has already sailed in the case of this code you’ve inherited. 😉

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

Sidebar

Related Questions

I am working with some legacy (circa 2003) javascript and html code and need
I'm working with some legacy code and need to change the background color of
I'm working on some legacy code/database, and need to add a field to the
I am working on some legacy code running Spring 2.5. I need to use
I am working with some legacy C code which I need to refactor and
I am working with some legacy code, and at some point there is a
I'm working in a WCF project and we need to reuse some legacy components
Working on some legacy hibernate code. How do I do the following with hbm.xml(hibernate
Working in some legacy code, I've run across a ton of Try/Catch statements. Try/Catch
I'm working with some legacy code that has an import like so: #import C:\Program

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.