word: minify put.js library using uglifyjs
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 25 Oct 2021 21:04:23 +0000 (23:04 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Nov 2021 03:14:15 +0000 (04:14 +0100)
Reduce download size from 3.4kB compressed to just 1.2kB.
Dependency node-uglify chosen because of Debian availability.

.gitignore
Makefile
word/memory.plp
word/quiz.plp

index 811bb088367319c258b55907d101d3f5dc9fde8f..f0359069c9536a442fe7db63ae3af7c9d5e677b4 100644 (file)
@@ -5,6 +5,7 @@
 # derived contents
 /sitemap.xml
 /light.css
+/word/*.min.js
 
 # site owner tag for google webmaster tools
 /google????????????????.html
index 0742e97654e9cd629c1ef3f6c4ecf9f4b10511e3..2e2b80a93ee461aa3ffe3cb6ee29d9f736c86cdb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,10 +17,12 @@ sitemap.xml: tools/mksitemap
 light.css: tools/stripcss base.css
        $(call cmdsave,$^)
 
-word: word/put.js data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json
+word: word/put.min.js data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json
 
 word/put.js: $(download)
        tools/wget-ifmodified https://github.com/kriszyp/put-selector/raw/master/put.js $@
+word/%.min.js: word/%.js
+       uglifyjs -m '' $< -o $@
 
 data/DerivedAge.txt: $(download)
        tools/wget-ifmodified http://www.unicode.org/Public/UNIDATA/$(@F) $@
index d12cc75d18023f71893727d3f4ecba22bc5ed15b..8847713d0bfbcbb44a3388f30ca12002a317efc7 100644 (file)
@@ -2,7 +2,7 @@
 
 Html({
        raw => <<'EOT',
-<script src="/word/put.js"></script>
+<script src="/word/put.min.js"></script>
 <script src="/word/memory.js"></script>
 <style>
 /* cards */
index 9d4afc8990413eece557226d7943fe47a688ebb6..00d82d27d36c441c13bacb833a23c266045db997 100644 (file)
@@ -2,7 +2,7 @@
 
 Html({
        raw => <<'EOT',
-<script src="/word/put.js"></script>
+<script src="/word/put.min.js"></script>
 <script src="/word/quiz.js"></script>
 <style>
 img {