From: Mischa POSLAWSKY Date: Sun, 11 Jun 2017 00:19:05 +0000 (+0200) Subject: common: generate optimised css file for light X-Git-Tag: v1.11~52 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/330e20e6262283b2e68fc22227672250849985e1 common: generate optimised css file for light Strip whitespace and comments to reduce download size by 6kB (35%). Silences site analysers such as Google PageSpeed about unminified CSS: > Compacting CSS code can save many bytes of data and speed up download and > parse times. > Minifying http://sheet.shiar.nl/base.css could save 2KiB (41% reduction) > after compression. Tried a couple of existing tools [from Debian] but they mostly failed to parse more complex rules, or tried to make unwanted "improvements". Rather write some simple regexes to specifically and transparently replace whitespace and comments. --- diff --git a/.gitignore b/.gitignore index bec2de1..5c53b31 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # derived contents /sitemap.xml +/light.css # site owner tag for google webmaster tools /google????????????????.html diff --git a/Makefile b/Makefile index a21f87b..349e34f 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ -all: sitemap.xml data/digraphs.inc.pl data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.inc.pl +all: sitemap.xml light.css data/digraphs.inc.pl data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.inc.pl more: all download: data/DerivedAge.txt data/rfc1345.txt data/xorg-compose data/countryInfo.txt data/browser/caniuse data/browser/usage-wm.tsv data/xcolors data/unicode-sampler .PHONY: download # atomically create file by command -cmdsave = @echo $1 $2 \>$@; mispipe '$1 $2' 'ifne sponge $@' +cmdsave = @echo '$1' $2 \>$@; mispipe '$1 $2' 'ifne sponge $@' # download git checkout gitsave = @if cd $@ 2>/dev/null; \ then echo git pull $@; git pull -q --ff-only || true; \ @@ -14,6 +14,9 @@ gitsave = @if cd $@ 2>/dev/null; \ sitemap.xml: tools/mksitemap $(call cmdsave,$<) +light.css: base.css + $(call cmdsave,perl -pe '\''s!\s*/\*.*\*/\Z!!; s/^\s*//; s/\h+/ /g; s/:\K\h+//;'\'',$<) + data/DerivedAge.txt: tools/wget-ifmodified http://www.unicode.org/Public/UNIDATA/$(@F) $@ diff --git a/light.css b/light.css deleted file mode 120000 index e734484..0000000 --- a/light.css +++ /dev/null @@ -1 +0,0 @@ -base.css \ No newline at end of file