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

What is a reasonable size of JavaScript? - Stack Overflow

programmeradmin2浏览0评论

What is the maximum size of JavaScript that would be reasonable for a web page? I have a JavaScript program with a data segment of size about 130,000 bytes. There is virtually no whitespace, ments, or variables in this file which could be minified. The file looks something like this:

"a":[0],
"b":[0,5],
"c":[3,4,24],
"d":[0,1,3],

going on for several thousand lines.

Google Analytics gives the following info on the connection speed of the current users:

Rank      Type     Visitors
1.        DSL         428
2.        Unknown     398
3.        Cable       374
4.        T1          225
5.        Dialup       29
6.        ISDN          1

Is the file size too much?

The alternative is using a server-side program with Ajax.

What is the maximum size of JavaScript that would be reasonable for a web page? I have a JavaScript program with a data segment of size about 130,000 bytes. There is virtually no whitespace, ments, or variables in this file which could be minified. The file looks something like this:

"a":[0],
"b":[0,5],
"c":[3,4,24],
"d":[0,1,3],

going on for several thousand lines.

Google Analytics gives the following info on the connection speed of the current users:

Rank      Type     Visitors
1.        DSL         428
2.        Unknown     398
3.        Cable       374
4.        T1          225
5.        Dialup       29
6.        ISDN          1

Is the file size too much?

The alternative is using a server-side program with Ajax.

Share Improve this question edited Dec 3, 2009 at 5:33 asked Dec 3, 2009 at 5:07 user181548user181548 1
  • The real question is how much are you willing to punish your users before they find something faster elsewhere... – austin cheney Commented Dec 3, 2009 at 13:37
Add a ment  | 

5 Answers 5

Reset to default 4

Better the small size better will be the load time. If you are too concerned with the file size then try gzipping it. You can also minify the js file.

Minifying js and css files is one of the performance rules that Yahoo suggests. For more detailed reading check this out.

Best Practices for Speeding Up Your Web Site

Edit

Check this one

How To Optimize Your Site With GZIP Compression

It depends on your users and what sort of connection speeds they have. With a 1 Mb/s connection or faster it probably wouldn't be too noticable, but with an older modem it would be very irritating having to wait 10 seconds or more.

You could try Minify to press your script: http://code.google./p/minify/

You can also load your scripts in the background using AJAX: http://betterexplained./articles/speed-up-your-javascript-load-time/

whatever your users will tolerate given their connection speed .. how long can they wait vs the benefit they gain for doing that ..

a download calculator might help ya

130k would take about 25-35 seconds to download on dialup.

As someone who is forced to use dialup two or three times a year, I'll tell you - if you're programming a web application that I wanted to use, I might stick around to use it. If it's just a site that I'm surfing to randomly, I'd be outta there :)

You should definitely look into minimizing the script. Looks like others have found the links before I did, so definitely check them out.

It is very impotent to speed up the web page load time to have small javaScript file There are some points

  1. Use external JavaScript file.
  2. Put all your JavaScript below body end tag.
  3. Try to minimize file size using tools mentioned above.

There are many more tips regarding this here

发布评论

评论列表(0)

  1. 暂无评论