From c24962392d8959eb912be14b225d2e8a08ae3f54 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Mon, 17 Aug 2015 14:51:14 +0200 Subject: jsgen: Support external command for JS compression (like uglifyjs) Tends to compress a bit better than JavaScript::Minifier::JS. But is also a lot slower, so not really useful when devving. Stats for en.js: raw gzip uglifyjs 68199 19446 JS::Minifier::XS 79862 21624 Uncompressed 107662 28663 On an unrelated note, I like how jQuery boasts about being "Only 32kB minified and gzipped.". That's quite a bit more than all of VNDB's Javascript combined. For a damn library. --- data/config_example.pl | 7 ++++++- data/global.pl | 12 ++++++++---- data/js/filter.js | 6 +----- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'data') diff --git a/data/config_example.pl b/data/config_example.pl index 56ed2ec7..9c255bb2 100644 --- a/data/config_example.pl +++ b/data/config_example.pl @@ -23,7 +23,7 @@ package VNDB; ); -# Uncomment to disable certain features of Multi +# Uncomment to enable certain features of Multi #$M{modules}{API} = {}; #$M{modules}{APIDump} = {}; @@ -35,3 +35,8 @@ package VNDB; # pass => '', # masters => [ 'yorhel!~Ayo@your.hell' ], #}; + + +# Uncomment the compression method to use for the generated Javascript (or just leave as-is to disable compression) +#$JSGEN{compress} = 'JavaScript::Minifier::XS'; +#$JSGEN{compress} = "|/usr/bin/uglifyjs --compress --mangle"; diff --git a/data/global.pl b/data/global.pl index c8f2537b..5cefa5ff 100644 --- a/data/global.pl +++ b/data/global.pl @@ -1,9 +1,6 @@ package VNDB; -our(%O, %S, $ROOT); - - # options for TUWF our %O = ( db_login => [ 'dbi:Pg:dbname=vndb', 'vndb', 'passwd' ], @@ -18,7 +15,8 @@ our %O = ( # VNDB-specific options (object_data) -our %S = (%S, +our %S; +%S = (%S, version => `cd $VNDB::ROOT; git describe` =~ /^(.+)$/ && $1, url => 'http://vndb.org', # Only used by Multi, web pages infer their own address url_static => 'http://s.vndb.org', @@ -136,6 +134,12 @@ our %M = ( ); +# Options for jsgen.pl +our %JSGEN = ( + compress => undef, +); + + # allow the settings to be overwritten in config.pl require $ROOT.'/data/config.pl' if -f $ROOT.'/data/config.pl'; diff --git a/data/js/filter.js b/data/js/filter.js index a9766f55..b1c7d581 100644 --- a/data/js/filter.js +++ b/data/js/filter.js @@ -345,9 +345,6 @@ function filFTagInput(name, label, type) { var src = type=='tag' ? '/xml/tags.xml' : '/xml/traits.xml'; var visible = false; - var remove = function() { - ; - }; var addtag = function(ul, id, name, group) { ul.appendChild( tag('li', { fil_id: id }, @@ -388,7 +385,6 @@ function filFTagInput(name, label, type) { txt.disabled = true; if(visible) ajax(src+'?'+q.join(';'), function (hr) { - var l = []; var items = hr.responseXML.getElementsByTagName('item'); setText(ul, ''); for(var i=0; i