码农日记

薄洪涛的个人博客

谷歌浏览器加载前端资源status=canceled

如图,今天在做弹出框(modal中用了iframe)的时候,发现模态框弹出的时候,会有一些前端资源加载被取消,但是也会有加载时间,影响页面的加载速度;然后我尝试用火狐,发现没有这个问题

TIM截图20190507133534.png经过一顿google,发现了出现canceled的原因

1.The DOM element that caused the request to be made got deleted (i.e. an IMG is being loaded, but before the load happened, you deleted the IMG node)

2.You did something that made loading the data unnecessary. (i.e. you started loading a iframe, then changed the src or overwrite the contents)

3.There are lots of requests going to the same server, and a network problem on earlier requests showed that subsequent requests weren’t going to work (DNS lookup error, earlier (same) request resulted e.g. HTTP 400 error code, etc)

就是说

1、加载的资源在加载的过程中被删除了,显然我不是这种情况;

2、你做了一些不必要的操作(其实就是我这种情况,我在弹窗外已经引用了js,css,然后在iframe中又引入了一次,这就重复了);

3、多次请求同一个服务器地址,如果前一个请求出错,后续的请求会自动取消;

于是我把iframe中的重复引入的资源注释调,bingo


  • 评论列表

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-BlogPHP 1.7.3

版权所有 | 转载请标明出处