WordPress site in China times out on requests to youtube [closed]

The Youtube is called by a script named “jquery.st.youtube.js” which is located in your themes folder. You seem to use a premium theme named “Wunder” which effectively means you can do one of two things:

1) You can edit the themes files directly, search for the enqueuing of the script jquery.st.youtube.js (most likely within the functions.php of the theme, but maybe somewhere else) and remove the line/turn the line into a comment. CAUTION: Do not do this if you plan to install updates to this theme. Whenever you update your theme, the changes you made are gone, so i would advise against this way. However, if the support cycle is over, you don’t plan to update the theme and need a quick dirty fix RITE NAO, it is a possibility.

2) You create a child theme (https://codex.wordpress.org/Child_Themes) of your premium theme. After that, find the handle which is used for enqueueing the “jquery.st.youtube.js”-Script. In the functions.php of your child-theme, you hook into the wp_enqueue_scripts action with a big priority like 1000 and use wp_dequeue_script to remove it from the action.

Example:
The function in your premium theme where the scripts are enqueued MAY look like this:

add_action( 'wp_enqueue_scripts', 'wunder_enqueue_scripts' );

function wunder_enqueue_scripts(){
   wp_enqueue_script('wunder-youtube',"jquery.st.youtube.js",array('jquery'),"",true);
..... (more scripts)
}

In your child-themes functions.php, you can now insert a function to dequeue the script like this:

add_action( 'wp_enqueue_scripts', 'remove_that_darn_youtube_scripts',1000 );

function remove_that_darn_youtube_scripts(){
   wp_dequeue_script('wunder-youtube');

}

If you don’t understand what any of these functions do, then you can read up on wp_enqueue_script and wp_dequeue_script in the wordpress codex (or you get someone to code for you 😉 )

While this is way more effort, i would suggest that you take route 2, as it is the “correct” way to do these things. Of Course, after you have built that child theme, you have to activate it for the changes to work.

Last but not least: DON’T DO THIS ON LIVE! Get yourself a backup of the site, and do the changes on local/a subsite/some other webspace and TEST IT before you put it on the live site!