1

My wordpress site dj.pyromusic.cn is based in China, on a chinese server. Somewhere in the theme, or the site, it is making a request to youtube which is obviously blocked here, causing the load time to be over 300 seconds before it times out.

Here is a screenshot of the inspection:

enter image description here

Any ideas how I can block this request?

1

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!

| improve this answer | |
  • Wow, thank you for an excellent answer. It make sense, and I can apply that, however I cannot find the .php file which contains the reference to jquery.st.youtube.js :/ – Spencer Tarring Jul 18 '18 at 11:05
  • I did however find the .js file, could I simply just rename/remove it? I guess that would cause many errors. – Spencer Tarring Jul 18 '18 at 11:07
  • I also now have a second one that is pending: monosnap.com/file/v9szXsqyz8RlHfbpZUdkCkMBU4xL2g Quite difficult to find these! Manually searched all the .php files. – Spencer Tarring Jul 18 '18 at 11:42
  • You can use a coding editor like notepad++ and use the "find in files"-feature to find it. Step 1) Connect to your Server per FTP and download the whole theme-folder. Step 2) use the "find in files" feature to search for the string "jquery.st.youtube.js" – HU ist Sebastian Jul 18 '18 at 11:43
0

OK, great I finally found the reference. It was in the file st.setup.php. I added a # to comment out the line, and it solved all the problems! Thank you and I will now try to create the child version.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.