简体   繁体   中英

Internet Explorer only part loading JavaScript/CSS

I'm having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I refresh, which suggested to me that it's trying to execute before it's finished loading or the connection was closed before it finished loading.

I've looked at the responses using Charles and Apache is returning the correct content-length header for the files I'm having trouble with but the text response is always truncated.

I also tried disabling g-zip compression, as I noticed that responses to IE don't have the Content-Encoding: g-zip header, but that breaks things in Firefox (in the same way) and doesn't fix the problem with IE.

I've looked at my Apache config and it is no different to the staging server where I'm not experiencing these issues.

I've changed this line:

BrowserMatch bMSIEs(7|8) !no-gzip !gzip-only-text/html

to this:

BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html

In my config and that seems to fix it, still not sure why it's working differently locally.

The directives causing the browser to load stuff - scripts, images, etc. are executed asynchronously. If your javascript is not self contained I mean relies on anything from any other file, you should not try to execute it using inline statements - you have no way of knowing whether this other file completed loading.

What you need to do is to trigger execution from the page loaded event

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM