Blake Butcher

Bookmarklet template

Bookmarklets are used to trigger some JavaScript on the currently open web page. This can be useful for many situations, such as:

I use the following code to create a bookmarklet link:

<a href="javascript:(function(){document.body.appendChild(document.createElement('script')).src=''+Math.floor(new%20Date().getTime()/(2*60*1000));})();">
	activate example bookmarklet

Which will render like so:

activate example bookmarklet

The users can then drags the link to their browser bookmark bar. From there they can click to activate the bookmarklet.

This bookmarklet itself just inserts a script tag that loads the specified external JavaScript file into the current page. In this case the external JavaScript just triggers a simple alert box.

It has a 2 minute cache-busting query string to ensure that the latest version of the JavaScript file is loaded.

The benefits of keeping the rest of your JavaScript outside of the bookmarklet are:

First post

This is my new personal website. It uses Twitter Bootstrap for the front end. It is stored in a GitHub repository and published using GitHub Pages with Jekyll templates. Posts are written in Markdown. And I’m using Google Analytics.