2

I have a web application that loads a handful of javascript (10-15) files per page. The problem I'm having is some of these files get "loaded" as blank files according to Internet Explorer 10 Developer Tools, but the problem is not consistently reproducible. If you refresh the page a couple times, the .js file does load properly. This issue happens if the file is loaded from cache (response 304) or if it's fresh from the server (response 200). We use CTRL+F5 to force a 200 response. Obviously a "blank" javascript file is throwing all types of errors because the code is simply not there to execute.

Screen shot #1: The javascript file in question is search.js. But as you can see in developer tools under the script tab the file is "blank". enter image description here

Screen shot #2: If we look under the network tab you can see the file was loaded OK enter image description here

Now here is where it gets interesting, if you click on "Go to detailed view" button the Response body for this file is the correct Javascript code. The Request and Response headers look correct as well.

Has anyone ever seen this before? We can't seem to reproduce this problem in Chrome or Firefox but that doesn't mean it's not happening there.

tk01
  • 97
  • 1
  • 11
  • Are you showing any script errors? There are times when a parsing error early in the file causes the script file to show empty in the debugger (because nothing was successfully parsed). This doesn't explain an intermittent problem (that would more likely be either a corrupted cache or a server issue), but it is a reason for blank source files. – jfriend00 Dec 30 '13 at 23:40
  • `` could be what you need. Most of those are showing up as `application/javascript`. – StackSlave Dec 30 '13 at 23:41
  • Search.js is not throwing any script errors. But other files that reference functions in search.js are throwing errors when they are trying to be invoked (as they should). Search.js isn't terribly complex, and I'm fairly certain the code in the file itself is fine because it loads properly on other occasions. – tk01 Dec 30 '13 at 23:44
  • Your fastest file is `type='text/javascript'`, which should be the default if left out, but might not be the case in the Browser mode you're using. Did you know IE11 is out? – StackSlave Dec 30 '13 at 23:45
  • @PHPglue interesting idea. I'll give it a shot. There seems to be some conflicting ideas on text/javascript and application/javascript though. http://stackoverflow.com/questions/876561/when-serving-javascript-files-is-it-better-to-use-the-application-javascript-or http://stackoverflow.com/questions/189850/what-is-the-javascript-mime-type-what-belongs-in-the-type-attribute-of-a-script/189877#189877 – tk01 Dec 30 '13 at 23:50
  • That text/javascript file is actually google-analytics ;) so it's no wonder it's so much faster. We're aware of IE11 but aren't quite compatible with it yet. Why do you ask? Is there something in IE11 that handles text vs. application? – tk01 Dec 30 '13 at 23:52

1 Answers1

0

<script type='text/javascript' src='wherever.js'></script> could be what you need. Most of those are showing up as application/javascript.

StackSlave
  • 10,613
  • 2
  • 18
  • 35