Bringing bookmarklets back with Clojure and Boot
- Bookmarklets are freaking awesome.
- Bookmarklets > browser extensions.
- Here's a nifty new open-source utility for building bookmarklets quickly.
But wait, what are bookmarklets again?
Well, according to bookmarklets.com:
Bookmarklets are simple tools that extend the surf and search capabilities of Firefox and Explorer web browsers.
So, they're, uh... well, I guess that's not very specific. When was this website made, 1998? Oh...
Wikipedia is more helpful, though:
If you were to drag that link to your browser's Bookmarks bar or folder, it becomes a convenient link that pops up the same alert no matter what page you're viewing.
- Modify the appearance of the current page, e.g. changing the background color or switching the font to something professional, like Comic Sans.
- Open a Google search in another tab for highlighted text.
- Replace all Japanese text on a page with an English translation.
- Submit the page to a bookmarking ("read this later") service.
I actually love Comic Sans! Why haven't I heard of bookmarklets before?
If you were a techie in the 90's and early 00's, chances are you know them. But in recent years they've fallen out of favor, and it's not 100% clear why.
One opinion is that the increased implementation of Content Security Policy (CSP) has hindered bookmarklet adoption. In short, when the page you're browsing is served over SSL (i.e. the URL begins with
Now, in the early 2000s, we didn't have services like Dropbox to do this easily...so it could have pushed away developers at the time.
A more likely explanation for the demise of bookmarklets is the rise of browser extensions.
Firefox add-ons and Chrome extensions are examples of browser-based programs that overlap with the functionality of bookmarklets. Indeed, extensions provide even deeper functionality, as they can tap into browser features like password and tab management.
But there are also some downsides to extensions:
- Slower: they run in the background and eat up CPU and RAM.
- Invasive: they have the potential to monitor your browsing history and steal your passwords.
- Complex: It's a lot harder to build than a bookmarklet. Each browser has its own documentation, process, and requirements.
- Unnecessary work: Amongst other things, you have to design an icon, decide what the drop-down menu contains, and build a tiny UI inside of a pop-up window.
For these reasons, it's my opinion that bookmarklets are preferable to extensions for many use-cases. Not only are they simpler to design, but they are better for the end-user (without whom, developers would, you know, cease to exist).
I'm sold. How do I build a bookmarklet?
Writing a bookmarklet in ClojureScript
Don't worry, this isn't a long, complex how-to guide. Rather, our team has already built tasks that automate the process!
Boot's belief is that any good build tool can automate the tedious parts of developing software. The Boot API lets Clojure developers write tasks that perform a specific operation on any project file.
To use our task, write code in a ClojureScript namespace and run
The next step to a working bookmarklet is to take the file, URL-encode it, and stick it in a
But why do it manually? Can't we automate that too?
boot-bookmarklet is a Boot task that fully automates the process described above.
Then, you can open
target/bookmarklets.html in your browser and drag the bookmarklet links into your bookmarks bar (or share with friends).
Voilà! You just made a bookmarklet, ClojureScript-style. It's scotch-time.
In case I've been wordy
To summarize, boot-bookmarklet gives you:
- A simple way to build arbitrarily complex bookmarklets.
- An ability to write in a well-designed programming language.
- A single command for generating the end result.
- A way to make your computer sing.
The bookmarklet Renaissance
I hope I've convinced you why it was a shame that bookmarklets went away. Will you help lead the comeback?