diff --git a/j/ga.js b/j/ga.js
index 9cea9e8..db5a8d5 100644
--- a/j/ga.js
+++ b/j/ga.js
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/publish b/publish
index 6b2c85f..32c60e6 100755
--- a/publish
+++ b/publish
@@ -93,14 +93,6 @@ done
# build sitemap
ls build/*.html | sed -e "s|build/|http://diveintopython3.org/|g" -e "s|/index.html|/|g" > build/sitemap.txt || die "Failed to build sitemap"
-echo "adding evil tracking code"
-
-# add Google Analytics script
-for f in build/*.html; do
- cat "$f" j/ga.js > build/tmpfile && \
- mv build/tmpfile "$f" || die "Could not add tracking code to $f"
-done
-
# minimize JS and CSS
echo "minimizing JS"
revision=`hg log|grep changeset|cut -d":" -f3|head -1`
@@ -123,19 +115,17 @@ java -jar util/yuicompressor-2.4.2.jar build/dip3.css > build/$revision.css && \
sed -i -e "s|;}|}|g" build/p-$revision.css || die "Failed to minimize CSS"
# put CSS inline and remove unused CSS properties on a page-by-page basis
-echo "inlining CSS"
+# minimize URLs by stripping "http:" prefix
+# add asynchronous Google Analytics script in head (after inline styles)
+echo "inlining CSS, minimizing URLs, adding evil tracking code"
+ga=`cat j/ga.js`
for f in build/*.html; do
css=`python2.6 util/lesscss.py "$f" "build/$revision.css"` || die "Failed to remove unused CSS"
mobilecss=`python2.6 util/lesscss.py "$f" "build/m-$revision.css"` || die "Failed to remove unused CSS"
printcss=`python2.6 util/lesscss.py "$f" "build/p-$revision.css"` || die "Failed to remove unused CSS"
- sed -i -e "s|||g" -e "s|||g" -e "s|||g" -e "s||g" -e "s|||g" -e "s|||g" -e "s||${ga}|g" "$f" || die "Failed to inline CSS"
done
-# minimize URLs
-echo "minimizing URLs"
-sed -i -e "s|=http:|=|g" build/*.html && \
- sed -i -e "s|href=index.html|href=/|g" build/*.html || die "Failed to minimize URLs"
-
# set file permissions (hg resets these, don't know why)
chmod 755 build/examples build/j build/i build/d && \
chmod 644 build/*.html build/*.css build/*.txt build/*.zip build/examples/* build/examples/.htaccess build/j/* build/j/.htaccess build/i/* build/i/.htaccess build/d/.htaccess build/.htaccess || die "Failed to reset file permissions"