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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:55:00+00:00 2026-05-30T04:55:00+00:00

I am trying to remove dependence on jQuery. I have stolen a couple of

  • 0

I am trying to remove dependence on jQuery. I have stolen a couple of functions I needed from underscore.js, but still need my code to run after the DOM is loaded in the same way as jQuery

Original

$(function(){
  // all my code
})

Desired

var afterload = function(content){
    // what goes here..?
}

afterload(function(){
    // my code that should run after the DOM is loaded
})
  • 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-30T04:55:02+00:00Added an answer on May 30, 2026 at 4:55 am

    There is a nice solution from https://github.com/freelancephp/DOMReady,

    Here is a script

    /**
     * DOMReady
     *
     * @fileOverview
     *    Cross browser object to attach functions that will be called
     *    immediatly when the DOM is ready.
     *    Released under MIT license.
     * @version 2.0.0
     * @author Victor Villaverde Laan
     * @link http://www.freelancephp.net/domready-javascript-object-cross-browser/
     * @link https://github.com/freelancephp/DOMReady
     */
    
    /**
     * @namespace DOMReady
     */
    var DOMReady = (function () {
    
        // Private vars
        var fns = [],
            isReady = false,
            errorHandler = null,
            run = function ( fn, args ) {
                try {
                    // call function
                    fn.apply( this, args || [] );
                } catch( err ) {
                    // error occured while executing function
                    if ( errorHandler )
                        errorHandler.call( this, err );
                }
            },
            ready = function () {
                isReady = true;
    
                // call all registered functions
                for ( var x = 0; x < fns.length; x++ )
                    run( fns[x].fn, fns[x].args || [] );
    
                // clear handlers
                fns = [];
            };
    
        /**
         * Set error handler
         * @static
         * @param {Function} fn
         * @return {DOMReady} For chaining
         */
        this.setOnError = function ( fn ) {
            errorHandler = fn;
    
            // return this for chaining
            return this;
        };
    
        /**
         * Add code or function to execute when the DOM is ready
         * @static
         * @param {Function} fn
         * @param {Array} args Arguments will be passed on when calling function
         * @return {DOMReady} For chaining
         */
        this.add = function ( fn, args ) {
            // call imediately when DOM is already ready
            if ( isReady ) {
                run( fn, args );
            } else {
                // add to the list
                fns[fns.length] = {
                    fn: fn,
                    args: args
                };
            }
    
            // return this for chaining
            return this;
        };
    
        // for all browsers except IE
        if ( window.addEventListener ) {
            document.addEventListener( 'DOMContentLoaded', function(){ ready(); }, false );
        } else {
            // for IE
            // code taken from http://ajaxian.com/archives/iecontentloaded-yet-another-domcontentloaded
            (function(){
                // check IE's proprietary DOM members
                if ( ! document.uniqueID && document.expando ) return;
    
                // you can create any tagName, even customTag like <document :ready />
                var tempNode = document.createElement( 'document:ready' );
    
                try {
                    // see if it throws errors until after ondocumentready
                    tempNode.doScroll( 'left' );
    
                    // call ready
                    ready();
                } catch ( err ) {
                    setTimeout( arguments.callee, 0 );
                }
            })();
        }
    
        return this;
    
    })();
    

    and you can use like this

    DOMReady.add(function (){
        alert( 'DOM is ready!' );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to remove dependency on jQuery from a project. Currently I have
Hello I was trying to remove objects from object array that I have and
I'm trying to remove part of the path in a string. I have the
I'm trying to remove scrollbar from my facebook app. I tried js solution, that
I'm trying to remove wiki formatting from some text so it can be parsed.
I'm trying to remove a specific graph object from the zedgraph, is it possible....?
I am trying to remove an object from an ArrayList and here is the
I am trying to write some code to optimize some Open GL functions for
So I'm trying to get class Herder to inherit from class Mob. But I
I donwloaded Moq.4.0.10827 from www.code.google.com/p/moq and trying to add reference to Moq.4.0.10827\NET40\Moq.dll to Visual

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.