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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:12:35+00:00 2026-05-29T10:12:35+00:00

Regarding this SO article and this SO article. I looked at these after noticing

  • 0

Regarding this SO article and this SO article. I looked at these after noticing my web app does not fire in IE8…I don’t care about backward compatibility at the moment but if it’s one line of code why not? Anyways the other issue I was having is the onload event waits for all the content to load…so the user has no controls if he/she is waiting for images to download. This led me to believe that I should just use

<script type='text/javascript'>my_initialize_function()</script>

placed in the html where I want the page to initialize.

and say to bye to

window.onload = initializePage;

or

window.addEventListener('load',initialize_page);

or any similar.

My question is: Is this a valid approach to initializing one’s page?

PS: I’m not using any libraries including JQuery…and obviously I would not try to initialize elements that have not been loaded yet.

  • 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-29T10:12:36+00:00Added an answer on May 29, 2026 at 10:12 am

    No.

    jQuery and similar libraries has an interesting approach. They simply capture different events in a crossbrowser manner while making it easier for the developer to use.

    Let’s consider the following code:

    <script> document.getElementById('a').innerHTML='b'; </script>
    <div id="a"></div>
    

    It may or may not work depending on whether the browser runs javascript when it finds it or only after the whole document has been built.

    On the other hand, if you used the proper event mechanism but the document has already been built, your code will not be called.

    jQuery unites both paradigms to get a seamless and better system. Something like so:

    var foo = {
    
      // holds list of callbacks to call when document starts
      stack: [],
    
      // document not ready yet
      ready: false,
    
      // add callback to be called when document is ready
      add: function(callback){
          foo.stack.push(callback);
          if(foo.ready)foo.fire(); // document is ready, call fire
      },
    
      // fire callbacks (document IS ready)
      fire: function(){
          for(var i=0; i<foo.stack.length; i++)
              foo.stack[i]();
          foo.stack = [];
    
          foo.ready = true; // document IS ready
      }
    
    };
    
    // bind to browser events
    window.onload = foo.fire; // TODO: you should use actual events
    
    // example of use
    foo.add(function(){
        alert('Document is ready!');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading this article on thedailywtf.com, I'm not sure that I really got the
After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile
I was under the impression, after reading this article that it is better to
I read this article regarding creating popup notes with javascript and css The problem
I was reading this interesting article regarding the display of the memory parameters in
I was looking at using Amazon's EC2 service after reading this article: http://www.ibm.com/developerworks/java/library/j-javadev2-4/index.html But
I found this article regarding Linq-to-SQL and SQL Server connection pooling: MSDN Blog From
I was reading this article: Managing Oracle Synonyms Regarding the order of preference, when
I have a question regarding this article. Between this code function odds(n, p) {
After reading this article I made a point that int () yields 0 because

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.