Skip to content

Commit

Permalink
split css/js into their single files to get async
Browse files Browse the repository at this point in the history
  • Loading branch information
noureddin committed Nov 7, 2023
1 parent 1329920 commit 4b97e1d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions .index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<<!!# 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.min.css>>
</style>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<input type="checkbox" id="dark" hidden disabled>
Expand Down Expand Up @@ -179,6 +177,6 @@
async src="//gc.zgo.at/count.js"></script>

<script src="res/jszip.min.js"></script>
<script><<!!cat scripts.min.js>></script>
<script src="scripts.min.js"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ J=deno run --quiet --allow-read npm:uglify-js -c passes=5 -m toplevel,reserved=$
C=deno run --quiet --allow-read npm:clean-css-cli
M=perl -CSAD minify.pl
P=perl -CSAD -nE 'while(s/<<!!(.*?)>>/`$$1`/ge){} print'
H=perl -CSAD -MDigest::file=digest_file_base64 -p \
-e 'sub hash(_) { digest_file_base64($$_[0], "SHA-1") =~ tr[+/][-_]r }' \
-e 's{(<script src="|<link [^<>]+ href=")([^"<>]+\.[^/]+)(?=")}{ "$$1$$2?h=" . hash($$2) }ge'


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

%.min.css: %.css
$C "$<" > "$@"
Expand Down
2 changes: 1 addition & 1 deletion index.html

Large diffs are not rendered by default.

0 comments on commit 4b97e1d

Please sign in to comment.