Skip to content

Commit

Permalink
Defer font tracking css script until after initial page load
Browse files Browse the repository at this point in the history
earlier today i saw the page load being blocked on retrieving
hello.myfonts.net and it made me mad enough to make this commit
  • Loading branch information
tjgrathwell committed Mar 12, 2014
1 parent accd9b9 commit 9b0f435
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ group :assets do
gem 'handlebars_assets'
gem 'jquery-datatables-rails'
gem 'sass-rails'
# sass_rails_patch allows 'css.scss.erb' to work.
# delete this when upgrading to rails 4 (sass-rails 4.0.0 incorporates a similar fix)
gem 'sass_rails_patch'
gem 'compass-rails'
gem 'coffee-rails'
gem 'uglifier'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sass_rails_patch (0.0.2)
sass-rails
select2-rails (3.5.2)
thor (~> 0.14)
sentry-raven (0.7.1)
Expand Down Expand Up @@ -383,7 +381,6 @@ DEPENDENCIES
rspec-rails
sanitize
sass-rails
sass_rails_patch
select2-rails
sentry-raven
sextant
Expand Down
9 changes: 9 additions & 0 deletions app/assets/javascripts/font_analytics.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% if Rails.env.production? %>
$(document).ready(function () {
var fontTracking = document.createElement('link');
fontTracking.type = 'text/css';
fontTracking.rel = 'stylesheet';
fontTracking.href = '//hello.myfonts.net/count/262127';
document.getElementsByTagName('head')[0].appendChild(fontTracking);
});
<% end %>
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<% if Rails.env.production? %>
/* font analytics for licensing */
@import url("//hello.myfonts.net/count/262127");
<% end %>

@font-face {
font-family: 'Freehand521BT-RegularC';
src: url('/assets/freehand.eot');
Expand Down

0 comments on commit 9b0f435

Please sign in to comment.