Excluding x-theme relevant js from Defer parsing of JavaScript

Hello,

i am using the plugin speed booster to optimize the page speed of my website https://einkaufchip.de.
When I enable the option “Defer parsing of javascript files” some elements of x-theme and cornerstone do not work any more for example:

  • Sliders by Revolution Slider,
  • the classic sliders
  • the dropdown of my main nav bar
  • classic card

Here is a list of all script handle:

wpac_time_js

jquery-core

jquery-migrate

tp-tools

revmin

jquery-ui-core

upcp-theme-js

upcpjquery

modernizr

touchSwipe

wprmenu.js

pdfjs

wppdf

jquery_magnific_popup

jquery_modal

gtm4wp-form-move-tracker

x-site-head

cornerstone-site-head

hoverIntent

x-cranium-migration-head

goop

upcp-page-builder

gridster

wf-cookie-consent-cookiechoices

x-site-body

comment-reply

cornerstone-site-body

x-cranium-migration-body

wp-embed

rplg_js

Please can you help me which scripts I should exclude from defer parsing that the x-theme and cornerstone elements stille work?

Thank you so much.

Best regards

Mario

Hi Mario,

Please exclude these files:

  • x-site-body
  • x-cranium-migration-body
  • x-cranium-migration-head
  • x-site-head
  • cornerstone-site-head

Let us know how it goes!

Hello, thank you very much. The plugin Speed Booster has only 4 possibility to exclude the files.
I added this code in the x-theme functions.php file to exclude this 5 files you told me.

add_filter (‘sbp_exclude_defer_scripts’, ‘my_function_name_here’);
function my_function_name_here( $array ) {
$array = (‘x-site-body’,‘x-cranium-migration-body’,‘x-cranium-migration-head’, ‘x-site-head’, ‘cornerstone-site-head’);
return $array;
}

But all the time I get this syntax error: syntax error, unexpected ‘,’

Please can you help me where the error is.

Thank you so much.

Best regards
Mario

Hi There,

Your code in incorrect. Please try with this code instead:

add_filter ('sbp_exclude_defer_scripts', 'my_function_name_here');
function my_function_name_here( $array ) {
	$array = array('x-site-body','x-cranium-migration-body','x-cranium-migration-head', 'x-site-head', 'cornerstone-site-head');
	return $array;
}

For more information about the array in PHP, please take a look at this:

http://php.net/manual/en/function.array.php

Hope it helps :slight_smile:

Thank you so much. I already said it several times but your support is GREAT!

Can I add the code at the end of the functions.php file your at one certain part of it? The last line is x_boot();

Thank you again.

Best regards

Hi There,

You should not do that. If you place the custom codes under the parent theme, they will be gone when you do the theme updates.

Please setup a child theme instead:

https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57

After that add your custom code under functions.php file locates in your child theme.

Regards!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.