Skip to content

Commit

Permalink
minify js, css, and html
Browse files Browse the repository at this point in the history
  • Loading branch information
noureddin committed Nov 7, 2023
1 parent 5e43a8e commit 1329920
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 2,658 deletions.
28 changes: 3 additions & 25 deletions .index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<<!!# this file uses a small preprocessor to embed fonts and data; see index.html for the generated HTML file>>
<<!!sh meta.sh>>
<style>
<<!!cat style.css>>
<<!!cat style.min.css>>
</style>
</head>
<body>
Expand Down Expand Up @@ -173,34 +173,12 @@
</div>
</div>

<script>
window.goatcounter = {
path: location.href,
allow_frame: true,
}
</script>
<script>window.goatcounter={path:location.href,allow_frame:true}</script>
<!-- privacy-friendly statistics, no tracking of personal data, no need for GDPR consent; see goatcounter.com -->
<script data-goatcounter="https://noureddin.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>

<script>
'use strict'
<<!!cat a.js>>
<<!!cat mappings.js>>
<<!!cat tajlorligilumi.js>>
</script>
<script src="res/jszip.min.js"></script>
<script>
'use strict'
<<!!cat data.js>>
<<!!cat versligilumi.js>>
// from: https://github.com/mathusummut/confetti.js. Copyright (c) 2018 MathuSum Mut. MIT License
<<!!cat res/confetti.min.js>>
<<!!#cat test.js>>
// remove the '#' in the previous line to perform the tests
<<!!cat javascript.js>>
<<!!cat res/jszip-utils.min.js>>
<<!!cat z.js>>
</script>
<script><<!!cat scripts.min.js>></script>
</body>
</html>
13 changes: 13 additions & 0 deletions .scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'
<<!!cat a.js>>
<<!!cat mappings.js>>
<<!!cat tajlorligilumi.js>>
<<!!cat data.js>>
<<!!cat versligilumi.js>>
// from: https://github.com/mathusummut/confetti.js. Copyright (c) 2018 MathuSum Mut. MIT License
<<!!cat res/confetti.min.js>>
<<!!#cat test.js>>
// remove the '#' in the previous line to perform the tests
<<!!cat javascript.js>>
<<!!cat res/jszip-utils.min.js>>
<<!!cat z.js>>
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
index.html: .index.html a.js data.js *.js *.css
perl -CSAD -nE 'while(s/<<!!(.*?)>>/`$$1`/ge){} print' "$<" > "$@"
R=$(shell perl -nle 'push @a, /\bon\w+="([^"]+)\(\)/; END { printf "[%s]\n", join ",", sort @a }' .index.html)
J=deno run --quiet --allow-read npm:uglify-js -c passes=5 -m toplevel,reserved=$R
C=deno run --quiet --allow-read npm:clean-css-cli
M=perl -CSAD minify.pl
P=perl -CSAD -nE 'while(s/<<!!(.*?)>>/`$$1`/ge){} print'


index.html: .index.html a.js data.js scripts.min.js style.min.css
$P "$<" | $M > "$@"

%.min.css: %.css
$C "$<" > "$@"

%.min.js: %.js
$J "$<" > "$@"

%.js: .%.js
perl -CSAD -nE 'while(s/<<!!(.*?)>>/`$$1`/ge){} print' "$<" > "$@"
$P "$<" > "$@"

scripts.min.js: .scripts.js a.js data.js *.js
$P "$<" | perl -CDAS -pe 's/const +say += +console\.log//' | $J > "$@"

.PHONEY: clean

clean:
rm -f index.html a.js data.js
rm -f index.html a.js data.js scripts.min.js style.min.css
Loading

0 comments on commit 1329920

Please sign in to comment.