The latest version of Thesis theme (v1.8) for Wordpress comes with built in support for Google Fonts. It’s nice and very easy to start using, but… not sure if you’ve noticed it already but use of Google Fonts (and other web “unsafe” fonts) may crash iPad’s Safari. This definitely is not something your visitors should experience visiting your web site.
So, I didn’t want to give up using extra fonts so I decided to modify Thesis a bit.
Import statement for Google Fonts is added as an include to layout.css. Thesis does a good job creating a custom layout.css when you save your preferences so it can be served without additional performance penalties. So, in order to conditionally serve CSS with or without Google Fonts, I first modified Thesis to generate additional layout_safe.css.
Change to functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
I added lines 5 and 12 that define THESIS_LAYOUT_SAFE_CSS.
Next I modified lib/classes/css.php that generates layout CSS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
I added lines 3, 6 (to add include to Google fonts only if we’re building “unsafe” CSS) and 21-28 (creating extra CSS file names layout_safe.css).
Note: You’ll need to create an empty layout_safe.css in your Thesis’ custom directory and make it writable by web server.
The next time when Thesis design options are saved, layout_save.css will be overridden with the CSS.
At the end, edit function stylesheets() in lib/classes/head.php to server layout_safe.css instead of layout.css when visitor is using iPad (or iPhone):
1 2 3 4 5 6 7 8 9 10 11
I added lines 7-10.
With these changes CSS server to iPad/iPhone users will not have import statement for Google fonts, falling back to default web-safe fonts.
Check caching plugins
There’s one more thing… If you’re using WPSuperCache (or some Wordpress caching plugin) make sure you edit .htaccess and add iPad to the list of user agents which are handled as mobile devices.