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

  • Home
  • SEARCH
  • 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 9238811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:50:51+00:00 2026-06-18T07:50:51+00:00

I created this script for a core.js file for my client’s website and I

  • 0

I created this script for a core.js file for my client’s website and I want to dynamically load a few javascript libraries from that core.js file. However, javascript libraries require that you load that library first, then use the rest of your script, because you have to define your libraries object before calling it, doh. So I have this very simple script to dynamically load a file, but I want to know if there’s a method to make sure that it loads it in priority ahead of the core.js file. Here’s the current script:

(function() {
    var script = document.createElement("script");
    script.setAttribute("type", "text/javascript");
    script.setAttribute("src", "http://modernizr.com/downloads/modernizr-latest.js");
    if(typeof script != "undefined") {
        document.getElementsByTagName("head")[0].appendChild( script );
    }
})();

And in the debugger, you see:

Of course, it’s going to load the dynamic file ahead of the core file, but I was wondering if there was a way to specify the line on the document for which to load the modernizr file? Otherwise, I can’t use Modernizr, even though I have loaded it.

Obviously, I can’t use jQuery, because I want to load that, too.

  • 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-06-18T07:50:52+00:00Added an answer on June 18, 2026 at 7:50 am

    You can respond to the loading of a dynamically-loaded JavaScript resource (or any resource, for that matter — image, iframe, video, etc.) with a load event listener. The easiest way to do it here would be:

    (function() {
        var script = document.createElement("script");
        ...
        script.onload = function() {
            // this will run later, when the script loads
            // in this function you can safely use Modernizr
        }
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script task that executes a dynamically created SQL restore statement. This
I bought this program that created a pretty nice imageuploader flash script however I
I have this code in a .html.erb file: <script src=http://connect.facebook.net/en_US/all.js#xfbml=1></script> <script> FB.Event.subscribe('edge.create', function(response) {
I'm currently trying to load a sql script to create a HSQL database. This
I've created a script that downloads very large files from the internet. Something quite
I used this script to create a jQuery accordion. Check out the working jsFiddle
This is my SQL Script CREATE TABLE account_profile ( accnt_id int NOT NULL ,
This is an HTML scrip that I created. I am trying to include a
This is the first Python script I've tried to create. I'm reading a xml
I have a script which creates a user-defined object like this: obj = new

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.