3

It's been a common problem among my team for a while. For aparently no reason, IE8 only loads the scripts sometimes. I'm using asp.net mvc3 and some scripts are loaded through _layout.cshtml (which is like a master page that all my others pages inherits). The other bunch of scripts are loaded only when needed. I must mention that i began to use Head.js to load my scripts. I was actually hoping that it would fix the IE8 scripts load problem.

These problems don't occur on firefox or chrome (which is another motive i'm certain it only happens on IE). And as it seems, if a single script breaks on IE8, this break propagates through other scripts.

I understand this may be a problem too broad to be solved with just the forementioned situation. So what i'd like to know is have you had a problem like this? If yes, what did you do to solve it? I really appreciate some directions, since i have to use IE.

Here is the scripts that are being loaded on _layout.cshtml, in the order of loading:

  • Head.js;
  • jquery-1.5.1.min.js;
  • modernizr-1.7.min.js;
  • jquery-ui-1.8.11.min.js;
  • jquery.ui.datepicker-pt-BR.js;
  • jquery.validate.min.js;
  • jquery.validate.unobtrusive.min.js;

An these are some of the other scripts that i use on some pages (it's not in their order):

  • jquery-blockUI.js;
  • jquery.jqGrid-4.1.2.min.js;
  • jquery.orbit-1.2.3.min.js;
  • jquery.jqplot.min.js (and some of it's renderers);
  • jquery.form.wizard-min.js;
  • ZeroClipboard.js;

EDIT

As T.J. asked for some piece of code, since it would be to hard to identify the problem with only the name of scripts used, here it is.

Scripts loaded on _layout.cshtml

<head>
<script src="@Url.Content("~/Scripts/head.min.js")" language="javascript"  type="text/javascript"></script>

//Lots of css files loaded mostly through document.write

<script type="text/javascript" language="javascript">
        //        if (head.browser.mozilla || head.browser.webkit || head.browser.opera ||
        //      (head.browser.ie && (head.browser.version == '9.0'))) {
        head.js('@Url.Content("~/Scripts/jquery-1.5.1.min.js")')
                .js('@Url.Content("~/Scripts/modernizr-1.7.min.js")')
                .js('@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")')
                .js('@Url.Content("~/Scripts/jquery.ui.datepicker-pt-BR.js")')
                .js('@Url.Content("~/Scripts/jquery.validate.min.js")')
                .js('@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")');
        if (screen.width == 1024) {
            head.js('@Url.Content("~/Scripts/resolucao1024.js")');
        } else {
            head.js('@Url.Content("~/Scripts/resolucaoMaior1024.js")');
        }
</script>
@RenderSection("Header", false)
</head>

Scripts loaded on a charts and graphics page

@section Header{
<script type="text/javascript" language="javascript">
        head
        .js('@Url.Content("~/Scripts/jquery-blockUI.js")')
        .js('@Url.Content("~/Scripts/jqGridMVC/grid.locale-pt-br.js")')
        .js('@Url.Content("~/Scripts/jqGridMVC/jquery.jqGrid-4.1.2.min.js")')
        .js('@Url.Content("~/Scripts/jquery-ConfigAjax.js")')
        .js('@Url.Content("~/Scripts/jqPlot/jquery.jqplot.min.js")')
        .js('@Url.Content("~/Scripts/jqPlot/jqplot.highlighter.min.js")')
        .js('@Url.Content("~/Scripts/jqPlot/jqplot.dateAxisRenderer.min.js")')
        .js('@Url.Content("~/Scripts/jqPlot/jqplot.pieRenderer.min.js")')
        .js('@Url.Content("~/Scripts/jqPlot/jqplot.donutRenderer.min.js")')
        .js('@Url.Content("~/Scripts/jqPlot/jqplot.cursor.min.js")');
    </script>
}

EDIT 2

Oh! i forgot to mention that every time i call some javascript functionality, i use head(function() {}) instead of $(function(){}) (it's recommended on head.js site).

EDIT 3

As Zeta asked, i'm providing a print from IE console (it's from my charts and graphic page).

enter image description here

Since i'm brazilian, it's in portuguese. Simple to understand though: it means 'jqplot' is null or is not an object. Like jqplot was never loaded or had some problem during the loading.

AdrianoRR
  • 1,131
  • 1
  • 17
  • 36
  • Please **quote** the code and markup that loads the scripts. Just telling us what they are probably won't be enough to go on. – T.J. Crowder Feb 29 '12 at 13:44
  • Does this happen in production or when you are using the Visual Studio Development Server? – Niklas Feb 29 '12 at 13:46
  • I faced this problem so often before. But it happened only to localhost. Everything's alright with real server. – vantrung -cuncon Feb 29 '12 at 13:46
  • I get problems if I use `` that mysteriously clear up if I use `` if it helps any. – asawyer Feb 29 '12 at 13:50
  • @T.J.Crowder i understand, but i've mentioned before that if do that it would a very extense question, since i'd have to post every point which i call those scripts. Anyway, i'll post where i often call them. – AdrianoRR Feb 29 '12 at 13:50
  • @Niklas it's interesting. It happens on both enviroments, but it occurs more often on VS dev server. – AdrianoRR Feb 29 '12 at 13:51
  • @asawyer: Nothing mysterious about that, `` [is incorrect](http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work). – T.J. Crowder Feb 29 '12 at 13:56
  • @T.J.Crowder Interesting, thanks! I think the problem I had was some machine generated code was inserting the self closing tags in mvc2 if I recall correctly. – asawyer Feb 29 '12 at 14:01
  • Could you please provide the error log from the IE8 error console? Or is it empty? – Zeta Feb 29 '12 at 14:06

2 Answers2

2

I resolved doing this:

head.js("js/jquery-1.7.1.min.js",
 function() {
   head.js("js/script.js");
   head.js("js/script1.js");
   head.js("js/script2.js");
   head.js("js/script3.js");
});

Hope it helps

NickHTTPS
  • 744
  • 4
  • 16
1

Broad question, so I cant promise this will fix it.

But I think about a year ago I had a problem with IE8 and script tags which sounds just like yours.

I noticed that if the script tag did not have all the added extras:

type="text/javascript" language="javascript"

and the server did not send http header-> content type: text/javascript

It did not work.

Give it a check, but thats all I got

Roderick Obrist
  • 3,688
  • 1
  • 16
  • 17
  • If so, that would be a **huge** new bug in IE8. I think it's extraordinarily unlikely. (And note that the `language` attribute has been deprecated for at least a decade, there's never any reason to include it.) – T.J. Crowder Feb 29 '12 at 14:06
  • Nope, i've added both type and language in all my scripts call. Anyway, thanks for the answer. – AdrianoRR Feb 29 '12 at 14:17
  • I'm aware of the depreciated thing. But thats what happened. I'm not saying that the language was what made or broke it. I listed three things I changed to turn IE8 from not downloading/parsing to downloading/parsing. – Roderick Obrist Feb 29 '12 at 14:21
  • I have a script that is not loading in IE8. I don't have the script type specified so this is the first thing I will try. How can I look in to the http header...i would have guessed this is automatic –  Mar 07 '13 at 16:01