Chrome只是没有完成加载JS文件 [英] Chrome just doesn't finish loading JS files

查看:269
本文介绍了Chrome只是没有完成加载JS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在< head> 部分编写了一个包含大约12个简短JS文件的应用程序(我知道,我应该合并它们并在结束之前移动它们< body> ;会在制作时得到这些)

麻烦的是当我尝试在Chrome中加载应用程序,有些文件立即加载,有些则永远无法完成加载! Chrome继续尝试加载12个JS文件,并且在我点击停止之前从不呈现页面。



当我点击停止时,HTML呈现出来并且JS文件失败,如下图所示:



请注意,不同的JS文件失败每次尝试!它不是每次都卡住的文件!

检查失败文件的标题显示警告:请求尚未完成。这些文件有时会持续很多分钟!





现在这里有趣的部分,在停止之后,如果我专注于omnibar并按Enter键,所有JS文件立即加载和应用程序正常工作!



在服务器端,我使用Apache,PHP和MySQL。我在Apache中配置了错误的东西吗?

在经历了2个艰苦的日子之后的状态:zilch,nothing,nada,这使我疯狂。我试图从不同的机器运行代码,试图更改apache缓存设置,并在JavaScript中改变了无数的东西,但没有任何工作。最糟糕的是,没有人可以指出问题所在! 解决方案

它不能正常工作。我以前见过这个。浏览器建立连接到服务器的最大数量(通常为6),以下载前几个文件(CSS,JS等),然后这些连接在超时之前不会被释放。我的症状与您的症状并不完全相同 - 超时时间为20秒,之后所有内容将分批加载6次 - 但这仍然是原因。



在你的Apache配置(大多数系统上的httpd.conf),查找 KeepAlive 行(或者添加它,如果缺失的话)并将其设置为 Off


I am writing an app that includes about 12 short JS files in the <head> section (I know, I should merge them and move them just before the end of <body>; would get to those when in production)

The trouble is that when I try to load the app in Chrome, Some files load immediately while some never finish loading at all! Chrome keeps trying to load the 12 JS files and never renders the page until I hit "Stop".

When I hit stop, the HTML is rendered and the JS files fail as in the image below:

Note that different JS files fail on each attempt! It's not the same file that gets stuck every time!

Inspecting the headers of the failed files shows "Caution: request is not finished yet". The files are stuck in "Receiving" sometimes for many minutes!

Now here's the fun part, after hitting stop, if I focus on the omnibar and press enter, all the JS files load instantly and the application works fine!

On the server side, I am using Apache, PHP and MySQL. Have I misconfigured something in Apache?

STATUS after 2 gruelling days: zilch, nothing, nada, this is driving me nuts. I have tried running the code from different machines, have tried changing apache cache settings and changed myriad things in javascript but nothing has worked. The worst thing is that no one can pin point where the problem is!

解决方案

One possibility is that you have Keep-Alive enabled and it is not working properly. I've seen this before. The browser establishes it's maximum number of connections to your server (typically 6) to download the first few files (CSS, JS etc.) then those connections are not released until they time out. My symptoms were not quite the same as yours - the timeout was 20 seconds and everything would load in batches of 6 after that - but this could still be the cause.

In your Apache configuration (httpd.conf on most systems), look for the KeepAlive line (or add it if it's missing) and set it to Off.

这篇关于Chrome只是没有完成加载JS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆