最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

i know there's a limit to the number of style sheets a webpage can have, but what about attached javascript files? - Sta

programmeradmin2浏览0评论

IE has a limit of 31 style sheets (there are ways around that) but is there a limit to how many javascript files i can include? if i go above it, what happens?

i've got a page now with 40+ included js files.

IE has a limit of 31 style sheets (there are ways around that) but is there a limit to how many javascript files i can include? if i go above it, what happens?

i've got a page now with 40+ included js files.

Share Improve this question asked Nov 11, 2010 at 20:32 changokunchangokun 1,5933 gold badges20 silver badges27 bronze badges 6
  • is there a reason you can't bine and minify the js files? – zzzzBov Commented Nov 11, 2010 at 20:35
  • 2 Q: if i go above it, what happens? A: Nobody knows because everyone who has tried it has perished. – jessegavin Commented Nov 11, 2010 at 20:46
  • I'd love to know what needs you have for including 40 separate .js files. – dmackerman Commented Nov 11, 2010 at 20:47
  • @zzzzBov: It's irrelevant. Some people just like to know these kind of limits. Optimization into single file is (imho) a step you perform when publishing the site to production. During development/debugging we want separate files because it makes live easier. – Stijn de Witt Commented Sep 11, 2013 at 7:09
  • @dmackerman: 40 is nothing. If you try to approach a web application in a modular fashion and make ponents for things like a RichTextArea or a TreeView etc, it's very natural to give each ponent a separate file. Getting 40 files is than just a matter of placing many ponents on the same page. – Stijn de Witt Commented Sep 11, 2013 at 7:11
 |  Show 1 more ment

2 Answers 2

Reset to default 11

I tried it myself and can now say that you can safely import and execute at least 200 JavaScript files in your HTML via script tag with the src-attribue with the following browsers:

  • Win XP IE6,
  • Win XP IE7,
  • Win XP IE8,
  • Windows 7 IE9,
  • Mac OS X Lion Chrome 21,
  • Mac OS X Lion Firefox 15,
  • Mac OS X Lion Opera 12,
  • Mac OS X Lion Safari 6.

Due respect, I think you're asking the wrong question. The correct question is: "I have 40+ JS include files...how do I fix it?"

Check out Google's article on reducing http round-trips, and the benefits of doing so. Combine, minify and deliver your files via gzip whenever possible.

The page not working is one concern, and a valid one...but why not side-step it and greatly improve your users' load time while you're at it by bining and minifying those files now, before you approach any limit? For mobile users round-trips are especially painful, but there's no reason not to offer a more optimal load experience to all your users.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论