an official release of prototype.js minified ?

1,049 views
Skip to first unread message

liketofindoutwhy

unread,
Oct 10, 2008, 2:54:55 AM10/10/08
to Prototype & script.aculo.us
would it be helpful if we have an official version of prototype.js
minified? if google can host it on their CDN (content delivery
network similar to Akamai), then we can all use it?

http://code.google.com/apis/ajaxlibs/documentation/index.html#prototype

(the link we can use in our code to get prototype.js)
http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js

is it true that the other thing that can help is gzip, but it is
entirely up to the browser/server to for it to kick in? so i heard
that Dean Edwards's packer can shrink it, but we might not want JS
itself to expand the code for us, as the speed for doing that can be
quite unknown. (gzip on the other hand will be something like the
speed of purely machine code).

I also wonder if the CDN gives an expiration of a few years into the
future like year 2010, then it may help too if we don't ever update
1.6.0.3's content and when we do, we always name it a different
version number, then the browser won't even need to recheck whether
the file needs an update from the server.



T.J. Crowder

unread,
Oct 10, 2008, 3:28:45 AM10/10/08
to Prototype & script.aculo.us
Hi,

Conveniently, there's just been a discussion about this over in the
Core group:
http://groups.google.com/group/prototype-core/t/61ea330c6977606c

Some quick answers, mostly from that thread:

1. There is no official minified version or anything like that.
There's really no need for one.

2. There's a packed version that JDD maintains; see his comments here:
http://groups.google.com/group/prototype-core/msg/6265ed854cd2ec3f
It's not official, but everyone here knows JDD (or should) and you can
trust him.

3. Yes, gzip helps a lot -- Prototype is about 28k gzipped. Yes, both
the browser and server have to support it. All major browsers do.
All major servers do. You have to configure it, which varies by
server. There's a thread about doing it with Apache:
http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/3a9e634a63afc5c0/bb512d5fe0b8fffa?lnk=gst#bb512d5fe0b8fffa
No specific thread about nginx that I've seen, but it's dead easy, see
the nginx docs:
Russian: http://sysoev.ru/nginx/
English (wiki): http://wiki.codemongers.com/Main

4. It's on the Google CDN (way cool!), which will gzip if the browser
supports it, does geographic coolness, and of course will be cached if
any previous site has used the same URL. The URL to use is:
http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js

HTH,
--
T.J. Crowder
tj / crowder software / com

On Oct 10, 7:54 am, liketofindoutwhy <liketofindout...@gmail.com>
wrote:
> would it be helpful if we have an official version of prototype.js
> minified?   if google can host it on their CDN (content delivery
> network similar to Akamai), then we can all use it?
>
> http://code.google.com/apis/ajaxlibs/documentation/index.html#prototype
>
> (the link we can use in our code to get prototype.js)http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js

liketofindoutwhy

unread,
Oct 10, 2008, 6:10:13 AM10/10/08
to Prototype & script.aculo.us
hm... i wonder if it is gzipped, then does the web server cache the
gzipped version, or does it gzip it every single time?

by the way, i just edited the Wikipedia entry for prototype, noting
the gzipped size is more accurate. Otherwise it won't do prototype.js
justice. Maybe that table can be expanded to list also the gzipped
sizes as well.

also... is it true that we don't need to minify it coz it saves only a
little? i thought even a little helps... and it only take a short
time to minify, and then it may be used by tens of millions of web
surfers world wide? thanks.


T.J. Crowder

unread,
Oct 10, 2008, 10:25:01 AM10/10/08
to Prototype & script.aculo.us
Hi,

> hm... i wonder if it is gzipped, then does the web server cache the
> gzipped version, or does it gzip it every single time?

It depends on the web server implementation. Nginx has specific
support for pre-gzipping things, called the "static gzip module".
Basically if it gets a request for the file "foo.html" from a gzip-
enabled client, it will look for foo.html.gz alongside foo.html in the
file system and, if found, use that to send back the gzipped result
without having to do it each time. Naturally you have to be sure your
deployment methodology prevents your updating foo.html and forgetting
to update foo.html.gz! No idea if Apache has a similar feature. I
mean, I'm sure it's possible with Apache through some form of hyper-
configuration (I'm pretty sure you can configure Apache to run NASA
and cure cancer), just no idea how easy or explicit it is.

> also... is it true that we don't need to minify it coz it saves only a
> little?

No. For instance, running Prototype through Crockford's jsmin[1]
takes it from 129,738 to 95,604 bytes (about 74% of the original
size). Gzipping those gives us 30,224 for the original, 23,969 for
the jsmin version, which is about 80% of the original size. So still
a substantial benefit, 6k out of 29.5k. jsmin is very conservative; I
would expect more aggressive ones like the modified version of
Edwards' Packer 3 that JDD uses that rename vars and such to give more
benefit.

[I'll emphasize that I *HAVE NOT* checked that jsmin'ing Prototype
doesn't introduce any problems. I haven't had trouble with jsmin
mucking up my own JavaScript though, as -- again -- it's quite
conservative.]

[1] http://www.crockford.com/javascript/jsmin.html
--
T.J. Crowder
tj / crowder software / com

On Oct 10, 11:10 am, liketofindoutwhy <liketofindout...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages