![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#1
IP: 49.87.51.150
|
|||
|
|||
|
wordpress大概从3.8版本开始会自动加载Google上面的Open Sans字体,并引用CSS样式。这些字体主要用于显示WP站点管理员登陆后顶部功能条的字体样式,而对于国内用户来说,Google会出现经常打不开或者访问速度过慢的情况,加载Google的字体无疑是自寻死路,直接影响站点后台的打开速度。如果你的模板也加载了Google字体,那么恭喜你:站点访问者都直接洗洗睡了!
通过观察代码可以看到,WP是这样加载字体的,在script-loader.php(wp-3.9)的580行代码进行加载。 Code:
<link rel="stylesheet" id="open-sans-css" href="//fonts.googleapis.com/css? family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600& subset=latin%2Clatin-ext&ver=3.9.1" type="text/css" media="all"> functions.php过滤 在主题中的functions.php文件末尾加上一下代码之一即可。此方法仅在前台有效,在后台界面无效,因为仅修改主题代码。 1. 代码一 Code:
// Remove Open Sans that WP adds from frontendif (!function_exists('remove_wp_open_sans')) : function remove_wp_open_sans() { wp_deregister_style( 'open-sans' ); wp_register_style( 'open-sans', false ); } add_action('wp_enqueue_scripts', 'remove_wp_open_sans'); // Uncomment below to remove from admin // add_action('admin_enqueue_scripts', 'remove_wp_open_sans');endif;
Code:
function remove_open_sans() { wp_deregister_style( 'open-sans' ); wp_register_style( 'open-sans', false ); wp_enqueue_style('open-sans',''); } add_action( 'init', 'remove_open_sans' );
由于最近谷歌被墙,很难打开,导致站点在引用谷歌上的资源,如字体、jquery等文件时,会出现严重超时的情况,最终导致站点打开速度极慢。 |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|