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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:51:36+00:00 2026-05-25T09:51:36+00:00

Background I’m developing a bookmarklet which has dependencies on 3rd party libraries to be

  • 0

Background

I’m developing a bookmarklet which has dependencies on 3rd party libraries to be loaded into the DOM before my bookmarklet script can run. The heart of the problem I’m having is this dependency chain that I need to wait for before I can react, and I’m having issues getting it to fly in IE.

I cannot be sure JQuery is even on the page at this stage. It’s something I check, and if it isn’t there, then I have to create and inject this into the DOM.

The flow of control is something like this:

  1. Load main library (jquery) into the DOM, I’ve attached an event listener to pick up on when it’s actually in the DOM.

    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = http:// ... jquerylibrary.js
    e.addEventListener('load', callback);
    
  2. Setup the callback function

    var callback = function() {
        //my stuff that wants to use jquery
    }
    

This works, and it works well. I can chain jquery, some jquery plugins, then my code, and then I can be sure when my code runs (in real browser land) that it’ll run.

The Crux of the problem

When IE > 9 (Which we must support) has a similar function … attachEvent('onload',callback);

Thing that’s similar, but doesn’t appear to fire correctly when DOM elements are updated. Looking through MSDN’s long list of events, it’s not clear if any of those events are what I’m looking for.

What event does IE 7+ fire when the DOM is updated?

  • 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-25T09:51:37+00:00Added an answer on May 25, 2026 at 9:51 am

    I’ve figured it out after reading some of the source of head.js. This calls for a bit of creative javascript magic.

    The events we’re interested in are onreadystatechange, and onload. You can attach a custom function to these to trigger update notifications when they insert into the page.

    I’ve abstracted this into a function, where, if you pass it an element and a callback statement, it’ll dump the element at the end of the page body and run the callback.

    function loadElement(e, callback) {
        if ( typeof(callback) === 'function' ) { 
            e.onreadystatechange = e.onload = function() {
                var state = e.readyState;
    
                if ( !callback.done && (!state || /loaded|complete/.test(state)) ) { 
                    callback.done = true;
                    callback();
                }   
            }   
        }   
        document.body.appendChild(e);
    }
    

    Though I’ve posted this answer to my problem, I’m interested in alternative approaches to this :).

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

Sidebar

Related Questions

Background I work for a large organization which has thousands of MS Access applications
Background This is only my second PyQt4 project. Developing a Windows app that has
Background: At my company we are developing a bunch applications that are using the
Background: I have a website that has been built with ASP.NET 2.0 and is
Background School Corp. has two databases with a common table, employees. These two databases
Background: I am customizing an existing ASP .NET / C# application. It has it's
Background I am developing a social web app for poets and writers, allowing them
Background Developing a simple web application (Eclipse + JBoss + Apache Tomcat) to generate
Background: I want to check-out the source code from Cliche , which is stored
BACKGROUND: Co-worker Adam has been using Google refine to process database downloads with much

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.