Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Created February 16, 2013 11:26
Show Gist options
  • Save toolmantim/4966482 to your computer and use it in GitHub Desktop.
Save toolmantim/4966482 to your computer and use it in GitHub Desktop.
Pre-fetching your Rails asset hostname using dns-prefetch in your application's layout file
<!DOCTYPE html>
<html>
<head>
<title>App title</title>
<% if ActionController::Base.asset_host %>
<link rel="dns-prefetch" href="//<%= ActionController::Base.asset_host %>" />
<% end %>
!!!
%html
%head
%title App title
- if ActionController::Base.asset_host
%link{rel:"dns-prefetch", href:"//#{ActionController::Base.asset_host}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment