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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:57:14+00:00 2026-05-30T22:57:14+00:00

I have built a javascript/css dependency manager similar to http://code.google.com/p/jingo/ . It allows me

  • 0

I have built a javascript/css dependency manager similar to http://code.google.com/p/jingo/.

It allows me to do something like this:

Loader.DependsOn(['/scripts/jqueryui.js', '/scripts/jquery.js'])
      .Css('/css/jquery.css')
      .Execute(function() { //Insert script here});

Loader will dynamically load both the script and the css before executing (if they haven’t been loaded already).

Everything is working, except in IE. The style sheets are loaded by appending a link to the head of the document. However, before doing this, the loader looks to see if the requested css file is itself dependent on another module. If it is, it will figure out where in the order of CSS files it should be inserted. In all browsers except IE, if I insert it at the beginning of the list, any other stylesheets after will override it’s styles (intended behavior). In IE, however, although it is inserted at the beginning, IE treats it as if it were at the end.

Is there a way to force IE to recompute styles?

UPDATED WITH TEST CASE:

Create two styles sheets, sheet1.css, sheet2.css

sheet1.css

.testdiv
{
    width:200px;
    height:200px;
    background-color:#c7c7c7;
}

sheet2.css

.testdiv
{
    width:400px;
    height:400px;
}

markup:

<html>
    <head>
        <link href="style1.css" rel="stylesheet" "type="text/css" />
    </head>
    <body>
        <div class="testdiv">
        </div>
    </body>
</html>
<script type="text/javascript" language="javascript>
     setTimeout(function() {

        var link = document.createElement('link');
        link.href = 'sheet2.css';
        link.rel = 'stylesheet';
        link.type = 'text/css';
        var head = document.head || document.getElementsByTagName('head')[0];
        head.insertBefore(link, head.children[0]);

        setTimeout(function () {
            //suggestion from Simon West
            document.body.className = document.body.className;
        }, 3000);

    }, 3000);    
</script>

What should happen:

Gray box 200px by 200px. After 3 seconds, it’s still there. No change.

What happens on IE8

Gray box 200px by 200px. After 3 seconds, it grows to 400px by 400px.

What happens on Safari (windows) –

Gray box 200px by 200px. After 3 seconds, it’s still there. No change.

This occurs with or without @Simon West’s suggestion.

  • 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-30T22:57:15+00:00Added an answer on May 30, 2026 at 10:57 pm
    <html>
    <head>
        <link href='sheet1.css' rel='stylesheet' type='text/css'>
    </head>
    <body>
        <div class='testdiv'></div>
        <script type='text/javascript'>
    setTimeout(function() {
        var link = document.createElement('link');
        link.href = 'sheet2.css';
        link.rel = 'stylesheet';
        link.type = 'text/css';
        var head = document.getElementsByTagName('head')[0];
        head.insertBefore(link, head.children[0]);
    
        var docElem = document.documentElement,
            docElemNext = docElem.nextSibling;
        document.removeChild(docElem); // this will clear document.styleSheets
        document.insertBefore(docElem, docElemNext);
    }, 500);
        </script>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built an object in Javascript on the Google Apps Script engine and
I am using the Syntax Highlighter built with Javascript by Alex Gorbatchev (http://alexgorbatchev.com/SyntaxHighlighter/download/) The
I have been using the JavaScript script VideoJS: http://videojs.com/ to build some video players
I've built a web application. In my application I have many javascript and css
Two part question: Do browsers have a built-in CSS interpreter like they do for
Does Javascript have a built-in syntax for selecting multiple variables? Say I'd like to
I have a javascript function that is being built to animate the collapse of
I'm trying to build something on javascript that I can have an input that
I have built an MSI that I would like to deploy, and update frequently.
I have built an application in C# that I would like to be optimized

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.