tags:

views:

108

answers:

5

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, comments, 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.

+3  A: 

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

rahul
I'm not sure what I do to gzip it, could you give an example? Do I write `src="myjs.js.gz"` in the HTML file?
Kinopiko
Edited my answer with a link on gzip compression.
rahul
Thanks, I'll have a look.
Kinopiko
+3  A: 

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 compress your script: http://code.google.com/p/minify/

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

Mark Byers
+1  A: 

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.

womp
+2  A: 

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

Scott Evernden
I accepted this because the download calculator was handy, but thanks to the other people who answered too.
Kinopiko
A: 

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

Umesh Aawte