pouët.net

1KB JavaScript Packer
[nfo]
screenshot added by whak on 2014-11-13 10:56:33
platform :
type :
release date : november 2014
  • 2
  • 3
  • 0
popularity : 56%
 56%
  • 0.40
alltime top: #26640
added on the 2014-11-13 10:56:33 by whak whak

popularity helper

increase the popularity of this prod by spreading this URL:

or via: facebook twitter pinterest tumblr bluesky threads

comments

Greets. I am a newbie here. I have been an admirer of the demo scene since mid 90s. Hope I am going about posting here right and hope not to annoy anyone (too much).

Anyhow...

In the screen shot you see 2 text boxes. Top is the original JavaScript source code & the bottom textarea is the generated packed script. This sample starts out with a 3,106 byte sample and packs it to 2,068 bytes. Not massive savings, but about 1/3 knocked off without any compression, isn't too bad.

My Google+: http://google.com/+DaveBrown
rulez added on the 2014-11-13 11:22:51 by whak whak
Great!

Would be great to see a benchmark, say, using the top 3 entries of the JS1k competitions, compared to other packers.

Please show the size of the original and final size.
rulez added on the 2014-11-13 15:42:16 by p01 p01
p01, oh wow. It really is a cut down version of my scriptcompress.com to demonstrate my original idea of simple search and replace to bring file size down. If the script doesn't have much repetition, then results will suck bad compared to other demoscene packers. But someone could pack with mine and then use another packer to packed the already packed.

I will work on some comparisons at least.

Size of original? The original of this script before I hacked it down was about 200KB, but after ridding of much of the minifying stuff (removal of comments, whitespace, cleaning, parsing, debugger), I was left with 2.5KB of HTML and JavaScript that I packed down to 0.99KB (had to add couple characters to make exactly 1,024 bytes.
added on the 2014-11-14 02:11:25 by whak whak
Updated it so you can see words being replaced. Now someone could just use it to to find all repeated phrases in their script and ignore the packer part. I sometimes throw in some HTML from a web page to suck out "keywords" for me and list them out.
added on the 2014-11-14 02:22:03 by whak whak
What packers should I compare against? I will do the benchmarks.

If you mean JSCrush, & Crunch, then I will not be able to compete fairly until a bigger script. My script can pack an entire Holy Bible down (from 4MB to less than 3), those other packers would crash and burn (they crash my browser if I try even a 10KB script).

Some ways mine is better, more ways theirs are better on small scripts. This is just an alternative.
added on the 2014-11-14 02:32:28 by whak whak
About the sizes, I meant the size of script before and after compression.

The main JS packers I have in mind are regPack, JS crush and First crush

I would be nice to see a benchmark with, say, the Top 3 entries of the last JS1k competitions, packed with these packers and yours, to get an idea of what kind of code they eat for breakfast.
added on the 2014-11-14 06:52:28 by p01 p01
I only intended this to be a 1KB release, not to compete. I can only beat results of them 3 packers on my scriptcompress.com, but it's a 300KB app (built in error fixing, minifing, rewrites code, etc).

When I do the benchmarking I will focus on the bigger 10KB and up realm. My little packer doesn't go as nuts as those regPack, JS crush and First crush. They look for any strings repeated, mine only looks for actual letter combinations (words/phrases) after stripping out all the non alpha characters.

This script isn't the best for extremely minified 2KB or less JavaScript.

This tiny script will usually beat Dean Edwards packer
added on the 2014-11-14 19:05:21 by whak whak
What I would find interesting: Are there any papers/info on what those JS crunchers do (besides minifying) and how they work, etc?
added on the 2014-11-14 21:00:16 by tomaes tomaes
tomaes: They all do similar things, they look for repetition to replace with a single character (usually single byte, but mine will go into 2 byte characters also). I just made one that does it less extreme (mine just looks for words and phrases, not punctuation and such) so it won't crash on bigger scripts (I find the Crush family crashes Chrome on scripts over 10KB, sometimes even over 2KB).
added on the 2014-11-15 00:23:53 by whak whak
I have found for the few experiments and two crappy demos I produced is that it may not always be in your best interest to remove all repetition if you intend to pack it in to a PNG. The packing process means that sometimes if you have something that's necessarily five characters, for whatever reason, if you use those five characters a few other times your output size doesn't always increase appreciably. Certainly not as many times as it was used.

This is of course hard to account for because you can't* know exactly how it's going to treat your stuff, except by experimentation. I found a few things where I had a general pre-PNG size reduction but the PNG size went up by anywhere from parts of to several kilobytes.

* Well, if you knew the innards of the particular deflate implementation of the PNG writer you're using, then maybe ... but I wouldn't think it likely.

Maybe other people who write better web demos than I do have better reasons to use a tool than I do for not. My workflow just involved a cobbled together Java app that would take my code, write it to the PNG file with an .html extension, then append that project's bootstrap code to the end of the file. The tool works, but it doesn't cover for the fact that I write crappy demos. ;P

(Daeken of course took this to the extreme and even figured out what parts of a PNG can be overwritten with parts of his bootloader and still be loaded correctly by the browser to save on space. I understand the idea, but now how he did it. My attempts resulted in broken images that didn't load.)
glad to see more js packers around, cool work. no rulez until it beats compression ratio of other packers though. ;)
added on the 2014-11-15 16:17:55 by psenough psenough
Thanks psenough. I made a better version on http://www.scriptcompress.com/JavaScript-Packer.svgz, but it's 38KB as I modded a parser that used Jquery (100KB JQuery file) and was 200+KB, but I rewrote it to not use Jquery (there goes 100KB addon no longer needed) and then packed (using scriptcompress.com) it to Bzip, embedded to a SVG and then Gzipped it, renamed to *.svgz to make it self extracting client side web app (it injects to an iframe). Now it's almost 10% of the size and includes my search/replace basic technique...
added on the 2014-11-20 21:55:52 by whak whak
psenough, It easily beats the most well known packer on the internet; http://dean.edwards.name/packer/ and that was my intention when I started making it...

Some comparisons of the 2 on http://www.scriptcompress.com/WHAK-PAK.htm
added on the 2014-11-22 17:09:57 by whak whak
http://www.scriptcompress.com/extreme.htm will beat jscrush sometimes, but works best on small JavaScript scripts around 1KB to 2KB (the app is bigger than 32KB so I will have to submit this version to a different category). Scripts larger than 2KB will not compute. This will definitely beat Dean Edwards Packer, Microsoft Ajax Minifier, Yahoo YUI Compressor & Google Closure Compiler (almost any tools on the net).

Just remember, it's not made for big scripts, it's too aggressive.
added on the 2014-11-25 05:41:28 by whak whak

submit changes

if this prod is a fake, some info is false or the download link is broken,

do not post about it in the comments, it will get lost.

instead, click here !

[previous edits]

add a comment