ElkArte Community

Title: Bananascript javascript scruncher
Post by: Antechinus on February 28, 2016, 02:39:18 pm
Was just wondering: back when the code for scrunching CSS and js files was being written, did you guys ever check out the code behind Bananascript (http://www.bananascript.com/index.php?compress)? It's capable of knocking down jquery_1.11.2.min.js from 94kb to 52kb, which is quite an improvement on an already minified library.

As far as I got when testing anything, the resulting code always worked. I was using it for scrunching SMF js files for custom theming too.
Title: Re: Bananascript javascript scruncher
Post by: Joshua Dickerson on February 29, 2016, 07:37:43 am
Where's the code at? Just looks like a service.
Title: Re: Bananascript javascript scruncher
Post by: Antechinus on February 29, 2016, 07:47:06 am
Dunno where it's hiding. I know Arantor managed to reverse engineer it. Which he said was a bit of a mission. Could try asking him about it.

Or, you could just ask the dude who wrote it if he would be prepared to part with code for a good cause.
Title: Re: Bananascript javascript scruncher
Post by: emanuele on February 29, 2016, 08:15:35 am
Since what it does is a sort of compression, wouldn't be easier to serve the files as gzip packages?

ETA: of course it doesn't mean it's easier because I always had problems in sending gzip instead of plain text files. O:-)
Title: Re: Bananascript javascript scruncher
Post by: Spuds on February 29, 2016, 11:16:22 am
Never heard of it before ...

Certainly doing some form of compression wrapper, gzip or other.   I'm probably wrong but I think that would mean the browser has to uncompressed the file each time its used?  Or maybe it can uncompress it just once to the browser cache?

You save some amount of single time bandwidth (since the files are cached by the browser) at the expense of the computational overhead of uncompressing them.  Not sure which would end up better, probably chasing gnat farts.
Title: Re: Bananascript javascript scruncher
Post by: emanuele on February 29, 2016, 11:22:34 am
What the site does is basically: convert all the js to a text string, find some repeated patterns and replace them with placeholders, then wrap everything into some code that, client-side, does the "counter replacement" putting back the repeated patterns and ends with an equivalent of eval(string_of_code).
Title: Re: Bananascript javascript scruncher
Post by: Antechinus on February 29, 2016, 03:14:20 pm
Yeah, what Ema said, AFAICT. Makes for very small files without gzipping.
Title: Re: Bananascript javascript scruncher
Post by: Spuds on February 29, 2016, 03:58:28 pm
So it does require the client to "unpack" the JS file before it can be used, and perhaps each time ... interesting concept, not sure  about whats really better for the client, a few more bits or a bit more processing.
Title: Re: Bananascript javascript scruncher
Post by: Antechinus on February 29, 2016, 04:02:28 pm
Dunno. If it aint done with CSS, I have no idea. :P I just thought it was interesting and was wondering if it was worthwhile.

It should give less load on the server, and less bandwidth usage. Client? Not so sure. I suppose I could drop the dude an email and ask.
Title: Re: Bananascript javascript scruncher
Post by: Joshua Dickerson on February 29, 2016, 04:37:08 pm
I think we're better off without having the client do decompression at the Javascript level.