admin管理员组文章数量:1417070
Let's say, a javascript tag's src attribute points to a redirect:
<script src=".js"></script>
where .js is a 301 redirect to .js...
Will all browsers successfully load the JS file? I've noticed it seems to work in Chrome, Firefox, Safari, and IE9... but I'm just curious if this is something that's in a spec or just random...
Let's say, a javascript tag's src attribute points to a redirect:
<script src="http://foo./foo.js"></script>
where http://foo./foo.js is a 301 redirect to https://foo./foo.js...
Will all browsers successfully load the JS file? I've noticed it seems to work in Chrome, Firefox, Safari, and IE9... but I'm just curious if this is something that's in a spec or just random...
Share Improve this question edited Feb 7, 2018 at 18:25 Yves M. 31.1k24 gold badges109 silver badges149 bronze badges asked May 31, 2011 at 2:51 Aaron GibralterAaron Gibralter 4,8733 gold badges37 silver badges50 bronze badges 4- 1 maybe you should go straight with https – Ibu Commented May 31, 2011 at 2:56
- 1 You can check out the following topic on behavior of different browsers to handle 301 redirect: stackoverflow./questions/2666089/… – rachel Commented May 31, 2011 at 3:07
- I think it will. Script requests are just regular browser HTTP requests (which will follow redirects). Unfortunately, I can't really cite anything to support this. – Cristian Sanchez Commented May 31, 2011 at 3:08
- Duplicates stackoverflow./questions/6381100/… and stackoverflow./questions/6456095/… – Yves M. Commented Feb 7, 2018 at 18:24
1 Answer
Reset to default 3Loading resources for a webpage (be it script source, image source or whatever) is agnostic to how browser fetches it for you (using HTTP protocol over TCP/IP).
The only thing to be aware of here is that browser makes two request to download one resource & provided that script calls are blocking in browser, so it is not advised to use this strategy for long. For the 3 very basic reason we use 301s are:
- Prettify URLs
- Ensure Link equity
- Resolve canonical issue.
本文标签: htmlWill JavaScript tag39s src attribute follow HTTP redirects in all browsersStack Overflow
版权声明:本文标题:html - Will JavaScript tag's src attribute follow HTTP redirects in all browsers - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745260516a2650336.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论