diff options
author | Mike Gerwitz <mtg@gnu.org> | 2019-01-19 00:50:06 -0500 |
---|---|---|
committer | Mike Gerwitz <mtg@gnu.org> | 2019-01-19 00:50:06 -0500 |
commit | 89328fe20611da1f34ac633de315a900254267c1 (patch) | |
tree | b0e159b2479d046012e781abff5deb517c6b9dc7 /Makefile | |
parent | 20a9d360777dc51341f93da9d9b8ba928c1402b5 (diff) | |
download | thoughts-89328fe20611da1f34ac633de315a900254267c1.tar.gz thoughts-89328fe20611da1f34ac633de315a900254267c1.tar.bz2 thoughts-89328fe20611da1f34ac633de315a900254267c1.zip |
Generate inline CSS for page header
The idea here is to provide as little CSS as is sensible for the initial
page load to be styled in a layout similar to the final layout. This
initial styling may be briefly visible on a slow conection.
Slow connections can happen for a variety of reasons. For example, I'm a
Tor user, and connection speeds vary. Mobile connection speeds can also
vary wildly.
This adds a few hundred bytes, but I was able to cut it down quite a bit,
and I don't find this to be unreasonable relative to the other data on
each page.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -59,6 +59,8 @@ www-pages = $(patsubst src/%, $(www-root)/%, $(srcpages)) www-files = $(www-pages) $(www-root)/style.css $(www-root)/rss.xml $(www-paper) \ $(www-images) $(www-fonts) $(www-root)/redirect-map.php +pgdeps := src/mkheader inline.css src/h12title src/header.tpl.htm src/footer.tpl.htm + RSS_N=10 export WWW_URL @@ -71,11 +73,11 @@ default: www-root src/post2meta $< > $@ src/talks.html: src/talks.rec src/papers.html: src/papers.rec -%.html %.xml: %.sh post/list src/mkheader src/header.tpl.htm src/footer.tpl.htm $(phtml) +%.html %.xml: %.sh post/list $(pgdeps) $(phtml) $< > $@ -%.html: %.md src/post2html src/mkheader src/h12title src/header.tpl.htm src/footer.tpl.htm src/pandoc.tpl +%.html: %.md src/post2html $(pgdeps) src/pandoc.tpl src/post2html $< > $@ -%.html: %.htm src/mkheader src/h12title src/header.tpl.htm src/footer.tpl.htm +%.html: %.htm src/mkheader inline.css src/h12title src/header.tpl.htm src/footer.tpl.htm src/mkheader about @__PAGE_TITLE__@ \ | cat - $< src/footer.tpl.htm \ | src/h12title @__PAGE_TITLE__@ \ @@ -95,6 +97,13 @@ post/list: $(pmeta) post/%.mk: post/%.meta build-aux/mkmk build-aux/mkmk $(www-root) $< > $@ +# Inline CSS for header (for initial page load). Blocks marked with +# `/*inline*/' are included. +inline.css: style.css + awk '/\/\*inline\*\/$$/,/^\}/{sub(/ *\/\*inline\*\//, ""); print}' $< \ + | sed 's/^ \+//g; s/ *\([{}>()]\) */\1/g; s/^ *\([^:]\+:\) */\1/g' \ + | tr -d '\n' > $@ + # Note the conditional include only for webroot. This is needed for two # reasons: # 1. To avoid including them on `clean' (see GNU Make manual, which is |