From c29b485df3475e251dce77e68d61462e2619ba9e Mon Sep 17 00:00:00 2001 From: raylu Date: Sat, 5 Nov 2011 03:14:50 -0700 Subject: fix async font/js loading issues --- css/page.css | 8 +++++++- includes/header.php | 27 ++++++++++++++++++--------- pages/home.php | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/css/page.css b/css/page.css index 2689aec..d38a21b 100644 --- a/css/page.css +++ b/css/page.css @@ -1,6 +1,12 @@ +html { + font-family: Helvetica, sans-serif; +} +html.wf-active { + font-family: Cantarell, Helvetica, sans-serif; +} + body { font-size: 16px; - font-family: helvetica, sans-serif; text-shadow: rgba(0,0,0,.01) 0 0 1px; /* this is definitely not a webkit-specific hack to fix font aliasing */ background-color: #121212; color: #ddd; diff --git a/includes/header.php b/includes/header.php index 1e24e8c..9340c3f 100644 --- a/includes/header.php +++ b/includes/header.php @@ -28,17 +28,26 @@ function htmlFooter() { _gaq.push(['_setAccount', 'UA-371072-3']); _gaq.push(['_trackPageview']); + WebFontConfig = { + google: { + families: ['Cantarell:400,700:latin'] + } + }; + (function() { - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + var proto = document.location.protocol; + var ga = document.createElement('script'); + ga.type = 'text/javascript'; + ga.async = true; + ga.src = ('https:' == proto ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; + s.parentNode.appendChild(ga, s); - var fo = document.createElement('link'); - fo.rel = 'stylesheet'; - fo.type = 'text/css'; - fo.href = "http://fonts.googleapis.com/css?family=Cantarell:400,700"; - var l = document.getElementsByTagName('link')[0]; l.parentNode.appendChild(fo); - document.getElementsByTagName('body')[0].style.fontFamily = 'cantarell, helvetica, sans-serif'; + var wf = document.createElement('script'); + wf.src = ('https:' == proto ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; + wf.type = 'text/javascript'; + wf.async = 'true'; + s.parentNode.appendChild(wf, s); })(); diff --git a/pages/home.php b/pages/home.php index 044fc5f..869c4d1 100644 --- a/pages/home.php +++ b/pages/home.php @@ -112,7 +112,7 @@ $mergesolution = $map; Copyright © 2011 pathery.com - +