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 --- includes/header.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'includes') 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); })(); -- cgit v1.2.3