9

I have external javascript files that get loaded in my master page.

Sometimes in IE8, my javascript files don't load correctly and the browser throws a bunch of javascript errors saying 'object not recognized.'

If I refresh the page then everything is fine. If I click on a link then the problem sometimes occurs again.

I have meta tags in my header for clearing out the cache on each request. I'm using the head.load library to load my js files in parallel.

The head.load library is located in my header and the external files are at the end of my body.

Please remember that this problem only occurs in IE8. So my question is..drum roll please..is there a hack that I can use to make sure my javascript files are loaded correctly each time the page loads for IE8?

Any help would be greatly appreciated.

Updated as requested

<head runat="server">
    <meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    <meta http-equiv="EXPIRES" content="-1" />
    <script type="text/javascript" src="scripts/js/head.load.min.js"></script>
</head>
<body>
<script type="text/javascript">
    head.js("scripts/js/jquery-1.6.2.min.js");
    head.js("scripts/js/jquery.cookie.js");
    head.js("lib/gritter/jquery.gritter.min.js");
    head.js("lib/fancybox/jquery.easing-1.3.pack.js");
    head.js("lib/fancybox/jquery.fancybox-1.3.4.pack.js");
    head.js("scripts/js/jquery.microaccordion.js");
    head.js("scripts/js/jquery.stickyPanel.js");
    head.js("scripts/js/guidely.js");
    head.js("scripts/js/pto.js");
</script>
</body>
7
  • Probably need to quote your head.load code. Commented Feb 20, 2012 at 19:10
  • throws a bunch of errors saying object not recognized specificity would help. Commented Feb 20, 2012 at 20:36
  • @damaniel, you say this code only fails in IE8. What are the other browsers you tested it on? Did you try an IE8 on another machine? Can you reproduce the problem in safe mode (-extoff command-line option)? Commented Feb 20, 2012 at 21:52
  • @Shad - objects not recognized means the objects that I am using in my application are not finding the external javascript files that the are supposed to be loaded and are not on page load in IE8. Forgive me I thought that was self-explantory. Commented Feb 22, 2012 at 14:37
  • @Frederic - I've tested in IE9, Chrome, Safari and Firefox. Not opera but I don't care about opera because this is an intranet site. I do care about IE because that is our standard. I've tried it on about 10 other machines. I'm using headjs.com and in IE8 it seems to not load the files sometimes. I'm not sure what you mean about running it in safemode this is a web application Commented Feb 22, 2012 at 14:42

2 Answers 2

2

Ok, the problems appears to be how the head.load library loads my externals in IE8. If I load jquery before I load the head.load library, and then load my externals in parallel at the end of the page; then there's no javascript errors. A little lesson for myself about javascript loading and IE8.

Thank-you everyone for the input.

@ frederic - I work at a company that has 188,000 employees. If a user has an add on installed in their browser that is causing my page to crash then there's nothing I can do about that. I also don't think this problem is being caused by any add ons. Its just how the head.load library is handled in IE8.

<head runat="server">
    <meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    <meta http-equiv="EXPIRES" content="-1" />
    <script type="text/javascript" src="scripts/js/jquery.min.js"></script>
    <script type="text/javascript" src="scripts/js/head.load.min.js"></script>
</head>

<script type="text/javascript">
    head.js("scripts/js/jquery.cookie.js");
    head.js("lib/gritter/jquery.gritter.min.js");
    head.js("lib/fancybox/jquery.easing-1.3.pack.js");
    head.js("lib/fancybox/jquery.fancybox-1.3.4.pack.js");
    head.js("scripts/js/jquery.microaccordion.js");
    head.js("scripts/js/jquery.stickyPanel.js");
    head.js("scripts/js/guidely.js");
    head.js("scripts/js/pto.js");
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, I don't want to be rude but your answer it may help with your particular problem but it's actually not solving the general problem on deps with headjs, consider to read my answer and maybe put a comment on yours.
0

Look at the page http://headjs.com/ in the section Usage you will see exactly what is wrong with your code:

// files are loaded in parallel and executed in order they arrive head.js("file1.js"); head.js("file2.js"); head.js("file3.js");

Your scripts are been loading in parallel and are executed in arrival time, that's pretty bad for the deps on jquery, if you want them to be executed in order use this:

head.js("scripts/js/jquery-1.6.2.min.js",
        "scripts/js/jquery.cookie.js",
        "lib/gritter/jquery.gritter.min.js"),
        "lib/fancybox/jquery.easing-1.3.pack.js",
        "lib/fancybox/jquery.fancybox-1.3.4.pack.js",
        "scripts/js/jquery.microaccordion.js",
        "scripts/js/jquery.stickyPanel.js",
        "scripts/js/guidely.js",
        "scripts/js/pto.js");

You need to call js with a list of resources to load, not just call js several times.

1 Comment

The documentation you speak of was not available a year ago when I actually encountered this problem and I'm pretty sure loading external files comma delimited wasn't a feature of headjs either....but its pretty cool that you can do that now...thanks for the input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.