Click anywhere to close

Highlight JS with Turbolinks

The Turbolinks gem doesn't let you use the $(document).ready() calls that highlight_js requires to highlight your code. Instead include the following at the bottom of your application.js:

$(document).on('page:change',  function() {
  $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});
$(document).on('page:restore', function() {
  $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});

This runs the text highlighting when the page is changed or restored using Turbolinks.

Source: http://kingori.co/minutae/2014/02/highlightjs-on-turbolinks/

Recent Posts

The future is multiplayer
Technology
posted: November 05, 2026
How we stay productive in the claude code era Two things always mattered for engineering productivity, but Claude Code makes them matter a lot more: managing many projects at once, and iterating as fast as possible.
Technology
posted: April 14, 2026
Not Enough People Are Talking About AI-Enabled Disruption The real winners of the AI wave will be people who figure out how to disrupt old industries by building AI-first companies.
Technology
posted: February 24, 2026
Engineering Culture at Hi Finance What we're building at hi finance, why we're building it, and the engineering values driving how we build it. Plus, we're hiring a Founding Engineer.
Technology
posted: February 16, 2026
AI Doesn't Change the Job of a Software Engineer Writing code is not, and has never been, the main job of a Software Engineer
Technology
posted: February 06, 2026