I just made a bunch of changes to the site here, which should make it run faster without visible effect. The details might be of interest to Web-tech and publishing-tech geeks. Plus, words on being sentimental about Perl code.
The H&J history · Back in 2011 I right-justified the text here, and for that to work you need hyphenation, which I did with Hyphenator.js on the grounds that “it makes perfect sense to run this sort of publishing busywork on the Web’s billions of underworked client systems, rather than on its millions of often-overworked servers.” [Pop quiz: What’s wrong with that thinking?]
That was fine, except for some combinations of Hyphenator.js and Internet Explorer apparently didn’t get along. To which it’s easy to say “get a better browser dammit” but lots of people don’t get to pick their at-work browser and who am I to interfere with people refreshing themselves with ongoing during working hours?
Answer to the pop quiz: Well, suppose you do the hyphenation on the
server-side once, at publication time. Enter
As of now, the text is published preloaded with soft-hyphen (U+00AD
It was something of a pain in the ass as a consequence of the fact that
Perl and Unicode
relationship problems (I recommend following that link).
I’ve been unable to figure out how to get the
UTF-8 out of the upstream XML files and through the Perl/MySQL pipeline and
into your browser without breaking it, so an early stage of the pipeline turns
all non-ASCII characters into XML character references,
­, and then TeX::Hyphen wanted to insert hyphens
into those, so a certain amount of backing and filling was required.
The Effects ·
Well, all the pages here are quite a bit bigger because they are now loaded
with 6-byte instances of
­ (those should be 2-byte UTF-8
characters but as I said, Perl and UTF-8, sigh). On the other hand, you don’t
have to fetch and run the 57K or so of Hyphenate.js, so I think it’s a win.
And one of these years I’ll wrestle the Perl/UTF-8 combo to the ground. Plus,
it should work in IE.
There is a bug: If you copy text out of ongoing, it’ll be festooned with those soft-hyphen characters, which shouldn’t actually cause any problems when you paste it in elsewhere, but are displeasing to the eye. I’ll have to cook up some JS to remove them; or rather, probably steal it from Hyphenate.js which I noticed takes care of that.
A lesson · Hm, I moved some reasonably complex application logic out of procedural code in the browser into server-generated declarative markup. This may be an unfashionable old-fart opinion, but I believe that’s generally a good thing to do.
Sentimental · Once a year or so I find myself fiddling with the publishing system here, which was whacked out quickly in 2002 and has thus been in production for a dozen years; 2,792 lines of Perl plus a supporting cast in JS and Ruby and SQL. The original design was ad-hoc, and then bits keep growing on the side here and there. On a couple of occasions I’ve been able to cut it down, but usually not.
But hey, it’s mine; an old friend now, flaws and all, and there are lessons there; not that I have any urge to share it. Maybe in a decade or two, at which point it’ll be a playground for software archaeologists.
Republishing the whole site from scratch takes a little under 10 minutes elapsed and burns 3:20 of CPU.