Published by Fabian on 09 Apr 2008 at 09:36 am
Javascripts should be fun and small
I rarely do blog posts just to link to somebody else, because I think my blog is not read by so many people that anyway wouldn’t have discovered that link otherwise.
So I suppose you seen this already Super Mario in Javascript made by Jacob Seidelin. There are many aspects of it what I like:
- Its fun to play
- It again proves that javascript is a language capable of doing such things
- It uses inline graphics. Thats right, no external files. While this is not a problem in any other scenario, in web it saves that extra http request, that with such small sprites adds a lot of overhead.
- It is awesome small. Just lately I played around with some Cover Flow js widgets (namely ProtoFlow and ImageFlow, in combination with HighSlide and LightBoxv2) and I was very disappointed that these libs are just that huge. I am willing to take extra bytes for eye candy, but I wont take 40KB just for opening a enlarged version of an image.
- It is compressed but not packed. Many people use Dan Edwards packer to make their Javascript smaller. This indeed brings a few bytes, however on every page load the browser has to unpack the script. Even the cached one! I found statistics on this some time ago, unfortunately cannot find them anymore, but they, additionally to common sense, convinced me that packing Javascript is not a good idea.
A very interesting idea is that he aliases some often used functions:
appChild = function(parent, child) {return parent.appendChild(child);}
by doing so YUI Compressor can shrink the method name, because its a local variable. Pretty neat idea.
Now back to ProtoFlow coding
Ah by the way, does anybody have a better,smaller alternative for lightboxv2?
Features should be: Fade background, display caption, handle multiple pictures in a row (next+prev) Autoresize to screen (a feature that LightBox doesn’t handle). Ideally it should use Prototype and scriptaculous, as this is already set for the project. And it should be small. YUI compressed less than 15k
Fabian on 09 Apr 2008 at 11:00 am #
Ah I found a very neat additional lightbox: http://www.nickstakenburg.com/projects/lightview/
but 40 kb compressed (not packed)
Henk on 14 Apr 2008 at 11:54 am #
Maybe this? http://www.digitalia.be/software/slimbox
Fabian on 15 Apr 2008 at 9:03 am #
Hi Henk,
I saw it already. I am a bit reluctant to add another JS lib to the site.
Mootools is something I really want to try, but most likely my next JS lib will be jQuery.
Even if the libs would interoperate nicely, its plenty of different libs users have to download. even if cached that additional lib would have to be parsed and run.
I feel not utterly happy with prototype and scriptaculous, due to the size of the libs (and I dont want to cut away parts of it myself)
Thanks anyway, and perhaps I end up using Mooooooooo