diff --git a/deploy.sh b/deploy.sh
index 6388e08..fde0e71 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -5,6 +5,8 @@ echo $rootdir
echo "Full Build"
./fullbuild.sh
+echo "Update file size"
+./update-file-size.sh
echo "Building RSS"
./mkrss.sh
echo "RSS Built"
diff --git a/project.el b/project.el
index 9b98333..4a6b3fd 100644
--- a/project.el
+++ b/project.el
@@ -105,6 +105,7 @@
"
"
(format "Generated: %s
"
(format-time-string "%Y-%m-%d %H:%M:%S"))
+ "Size: XXK (HTML: XXK, CSS: XXK, IMG: XXK)
"
(format (concat " Generated with "
"
Emacs %s, "
"
Spacemacs %s, "
diff --git a/project.el.sig b/project.el.sig
index 24e5852..d006152 100644
Binary files a/project.el.sig and b/project.el.sig differ
diff --git a/update-file-size.sh b/update-file-size.sh
new file mode 100755
index 0000000..3c13ffc
--- /dev/null
+++ b/update-file-size.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i zsh
+#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
+
+webdir="_site"
+
+sizeof() {
+ stat --format="%s" "$*"
+}
+
+debug () {
+ # print -- $*
+}
+
+toh () {
+ numfmt --to=iec $*
+}
+
+tmpdir=$(mktemp -d)
+for fic in $webdir/**/*.html(.); do
+ print -n -- "$fic "
+
+ htmlsize=$(sizeof $fic)
+ debug HTML: $htmlsize
+
+ xfic=$tmpdir/$fic
+ mkdir -p $(dirname $xfic)
+ hxclean $fic > $xfic
+
+ images=( $( < $xfic hxselect -i -c -s '\n' 'img::attr(src)' | sed 's/^\.\.\///' ) )
+ imgsize=0
+ nbimg=0
+ for i in $images; do
+ ((nbimg++))
+ isize=$( sizeof ${fic:h}/$i )
+ debug $i '=>' $isize
+ (( imgsize += isize ))
+ done
+ debug IMG: $imgsize
+
+ css=( $( < $xfic hxselect -i -c -s '\n' 'link[rel=stylesheet]::attr(href)'))
+ csssize=0
+ for i in $css; do
+ isize=$( sizeof $webdir/$i )
+ debug $i '=>' $isize
+ (( csssize += isize ))
+ done
+ debug CSS: $csssize
+ total=$(( htmlsize + imgsize + csssize ))
+ sizeinfos=$(print -- "Size: $(toh $total) (HTML: $(toh $htmlsize), CSS: $(toh $csssize), IMG: $(toh $imgsize))")
+ print -- $sizeinfos
+ perl -pi -e 's#(
)[^<]*(
)#$1'"$sizeinfos"'$2#' $fic
+done
+rm -rf $tmpdir