Habari Plugins: Cache Gists and an Update to Google Analytics
As of last night, this site is running on Habari again (from Drupal, from Nisaba, from Habari…). I am using quite a few plugins for site optimization — here are two. The Google Analytics plugin is originally by Graham Christensen, the Cache Gists plugin is my own creation. Both of these plugins were tested with version 0.6 of Habari.
Google Analytics
Drupal’s Google Analytics plugin had the useful ability to cache the analytics javascript file, which reduces the number of DNS lookups for visitors browsing your site. I decided to get my hands dirty, and added this option to the Google Analytics plugin from the Habari Extras repository.
While I was at it, I added https detection to the plugin. Stock Google Analytics code writes the script tag to the document after the page is loaded, but there are multiple issues with this feature, the primary one being that it doesn’t play nice with real XHTML documents. The Google Analytics plugin now writes the script location into the document before sending it to the client.
Download here: googleanalyticsextra-0.6 – 0.0.1.zip
Update 04.25.2009: Changes have been merged into the GoogleAnalytics plugin at Habari Extras.
Cache Gists
Similarly to the Google Analytics stock code, GitHub Gists are inserted into the document using document.write(). Unlike Google Analytics, Gists are usually right in the middle of page content, making document rendering jerky. This plugin caches the Gist to the webserver, avoiding document.write(). I published a previous entry about GitHub Gists here.The target audience for this one will be a small niche for sure, but here it is.
Future Updates
At some point, I may add the option to move the Gist stylesheet to the document head (if that’s possible) or strip the Gist stylesheet from page to allow for easier custom styling. Also, I’d like to look into creating a minify plugin for Habari. Stay tuned!
Need a minify plugin? Improve on this one:
http://trac.habariproject.org/habari-extras/browser/plugins/jsmincdn/trunk/jsmincdn.plugin.php