Solve the 2014 recent WordPress access to open slowly, and has been loading the page problem

Source: Internet
Author: User
Tags add functions php file access
The recent visit of WordPress Web site is particularly slow, there is time to load a minute to fully open, initially suspected that the problem of the server, after a lot of testing, or did not find the reason. Later, through the tool to detect the browser has been loaded fonts.googleapis.com, only to discover is the original Google's external chain resources affect the speed of the site! WordPress Many themes with Google's services, now Google is a large-scale shielding, speed has been affected. WordPress since 3.9+ version joined the Google Fonts, and the recent Google in China is not accessible, so, if you are in the landing state to open your WordPress site, it will be very slow, because it can not load this font file. If you are not logged in and your topic is not a foreigner's theme, it is generally normal. Solution: Come out of the problem to be solved, in the Celestial kingdom, since you have to endure it, then change a way of thinking. The following solution, the idea is to prohibit the loading of the Google Fonts, the second is to replace the load source. The following description: Method one: "plugin" prohibit wordpress background loading Google Fonts install Disable Google Fonts or Remove Open Sans font Link from WP core one can. There's nothing to say. Method Two: "Code" directly in the functions.php file to add code network has a lot of code, the following can be referred to, the specific effect is not confirmed: Add_filter (' Gettext_with_context ', ' Disable_open_ Sans ', 888, 4); function Disable_open_sans ($translations, $text, $context, $domain) {if (' open sans font:on or off ' = = $context && ' on ' = = $text) {$translations = ' off ';} return $translations;} function Dw_remove_open_sans () {wp_deregister_style (' Open-sans '); Wp_register_style (' Open-sans ', false); Wp_enqueue _style (' Open-sans ', '); } add_action (' init ', ' dw_Remove_open_sans '); Method Three: "Code" replaces the open sans font's loading source open the file wp-includes/script-loader.php file in the WordPress code, search: fonts.googleapis.com find this line of code: $open _ Sans_font_url = "//fonts.googleapis.com/css?family1=open+sans:300italic,400italic,600italic,300,400,600& subset= $subsets "; Replace the fonts.googleapis.com with the fonts.useso.com. WordPress has a lot of foreign themes are using Google's fonts, including the WordPress backstage itself is also in use, if Google suffered shielding, will lead to the use of WordPress site slow. Because each page switch needs to fetch fonts.googleapis.com, this link will be blocked because of Google. Front of the solution is to start from the theme, annotation related CSS, background methods are as follows: Remove WordPress backstage Google Font API link is the annual GFW blocked Google time period, children's shoes have no feeling backstage card it? That is because WordPress uses the Google font API, the solution is to temporarily remove the font file link. function Remove_open_sans_from_wp_core () {wp_deregister_style (' Open-sans '); Wp_register_style (' Open-sans ', false); Wp_enqueue_style (' Open-sans ', '); } add_action (' init ', ' remove_open_sans_from_wp_core '); Add this code to the functions.php file at the end of the topic directory. (Do not edit code with Notepad)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.