css e js
-
Hi, I’m using your plugin but I can’t exclude the css and js of a plugin I use, why don’t they appear? the plugin is “Events Shortcodes For The Events Calendar”
The page I need help with: [log in to see the link]
-
Hello @ilgrizly,
The drop-down exclude menu only lists scripts added through the default WordPress hooks. If a script is missing from the list, you can exclude it manually using one of the filters we’ve designed for that purpose. All available filters can be found here:
https://www.siteground.com/tutorials/wordpress/speed-optimizer/custom-filters/
The following post provides guidance on how you can find the script handle:
https://ww.wp.xz.cn/support/topic/how-to-use-sg-optimizers-filters-procedure/
Regards,
DimoI used all the filters made available but they don’t work, the Events Shortcodes For The Events Calendar plugin doesn’t work even though they gave me the complete list of all the scripts and css in use
template-events-calendar\assets\js\ect-notice.js
template-events-calendar\assets\js\ect-sharebutton.js
template-events-calendar\assets\js\ect-sharebutton.min.js
template-events-calendar\assets\css\ect-admin-notices.css
template-events-calendar\assets\css\ect-common-styles.css
template-events-calendar\assets\css\ect-common-styles.min.css
template-events-calendar\assets\css\ect-list-view.css
template-events-calendar\assets\css\ect-list-view.min.css
template-events-calendar\assets\css\ect-minimal-list-view.css
template-events-calendar\assets\css\ect-sharebutton.css
template-events-calendar\assets\css\ect-sharebutton.min.css
template-events-calendar\assets\css\ect-timeline.css
template-events-calendar\assets\css\ect-timeline.min.css
template-events-calendar\assets\css\shortcode-generator.cssadd_filter( 'sgo_css_combine_exclude', 'css_combine_exclude' );
function css_combine_exclude( $exclude_list ) {
// Add the style handle to exclude list.
$exclude_list[] = 'template-events-calendar\assets\css\ect-admin-notices.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-common-styles.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-common-styles.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-list-view.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-list-view.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-minimal-list-view.css'; $exclude_list[] = 'template-events-calendar\assets\css\ect-sharebutton.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-sharebutton.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-timeline.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-timeline.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\shortcode-generator.css';
return $exclude_list;
} add_filter( 'sgo_css_minify_exclude', 'css_minify_exclude' );
function css_minify_exclude( $exclude_list ) {
// Add the style handle to exclude list.
$exclude_list[] = 'template-events-calendar\assets\css\ect-admin-notices.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-common-styles.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-common-styles.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-list-view.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-list-view.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-minimal-list-view.css'; $exclude_list[] = 'template-events-calendar\assets\css\ect-sharebutton.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-sharebutton.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-timeline.css';
$exclude_list[] = 'template-events-calendar\assets\css\ect-timeline.min.css';
$exclude_list[] = 'template-events-calendar\assets\css\shortcode-generator.css';
return $exclude_list;
}
add_filter( 'sgo_js_minify_exclude', 'js_minify_exclude' );
function js_minify_exclude( $exclude_list ) {
$exclude_list[] = 'template-events-calendar\assets\js\ect-notice.js';
$exclude_list[] = 'template-events-calendar\assets\js\ect-sharebutton.js';
$exclude_list[] = 'template-events-calendar\assets\js\ect-sharebutton.min.js'; return $exclude_list;
} add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' );
function js_combine_exclude( $exclude_list ) {
$exclude_list[] = 'template-events-calendar\assets\js\ect-notice.js';
$exclude_list[] = 'template-events-calendar\assets\js\ect-sharebutton.js';
$exclude_list[] = 'template-events-calendar\assets\js\ect-sharebutton.min.js'; return $exclude_list;
} add_filter( 'sgo_js_async_exclude', 'js_async_exclude' );
function js_async_exclude( $exclude_list ) {
$exclude_list[] = 'template-events-calendar\assets\js\ect-notice.js';
$exclude_list[] = 'template-events-calendar\assets\js\ect-sharebutton.js';
$exclude_list[] = 'template-events-calendar\assets\js\ect-sharebutton.min.js'; return $exclude_list;
}Hello @ilgrizly,
Based on your latest update, the information about the styles and scripts you want to exclude is not properly set, which is why the filter is not working as expected.
What you have added in the exclude list is the full path to the .css/.js in use, however what you need to add the .css/.js handle only.
You’re welcome to check the topic previously provided: https://ww.wp.xz.cn/support/topic/how-to-use-sg-optimizers-filters-procedure/ on how to identify the handles.
Best Regards,
Gergana Petrova
so I should uninstall the plugin because otherwise it won’t show me the handles, then look for all the handles I need for a particular plugin which speed optimizer eliminates for me, then reinstall the plugin, unload another snippet plugin and then create infinite snipets for and test if it works, in the meantime I’ve had two children, a dog, car and house loan, found a lover and a second apartment and google has failed in the meantime waiting for covid 2 lol
Hello @ilgrizly,
What you need to do is make sure you found the proper handle to exclude. For example, if you intend to exclude the template-events-calendar\assets\js\ect-sharebutton.min.js handle, what you should add in the filter is the following:
$exclude_list[] = 'ect-sharebutton';Once you have excluded the handle, the issue should be resolved.
Best regards,
Daniela Ivanovaadd_filter( ‘sgo_js_minify_exclude’, ‘js_minify_exclude’ );
function js_minify_exclude( $exclude_list ) {
$exclude_list[] = ‘ect-hide-notice-js’;
$exclude_list[] = ‘ect-sharebutton’;
$exclude_list[] = ‘ect-feedback-notice-styles’;
$exclude_list[] = ‘ect-common-styles’;
$exclude_list[] = ‘ect-list-styles’;
$exclude_list[] = ‘ect-minimal-list-styles’;
$exclude_list[] = ‘ect-sharebutton-css’;
$exclude_list[] = ‘ect-timeline-styles’;
$exclude_list[] = ‘sg-btn-css’;
return $exclude_list;
}obviously <?php at the beginning of the string automatically puts it in the Snippet plugin
got all the handers from whoever built the plugin, I inserted them into the plugin snippet, I activated it but nothing, and then why is it that if I log in I see everything working and when I log out nothing works anymore? and it seems that the problem is only on desktop computers while on smartphones it changes but no script effect is seen
Hello,
Everything is working as expected when you are logged in to the backend of the website because the caching is disabled for logged-in users.
Please, make sure that the excluded handles are properly added to the website’s current theme’s functions.php file. If this does not resolve the issue, most likely something else installed on your website is interfering with the proper caching of your site. In this case, I would recommend you to disable other plugins or change the theme to find out exactly what is causing the issue.
Best Regards,
Daniela Ivanovaadd_filter( ‘sgo_js_minify_exclude’, ‘js_minify_exclude’ );
function js_minify_exclude( $exclude_list ) {
$exclude_list[] = ‘ect-hide-notice-js’;
$exclude_list[] = ‘ect-sharebutton’;
$exclude_list[] = ‘ect-feedback-notice-styles’;
$exclude_list[] = ‘ect-common-styles’;
$exclude_list[] = ‘ect-list-styles’;
$exclude_list[] = ‘ect-minimal-list-styles’;
$exclude_list[] = ‘ect-sharebutton-css’;
$exclude_list[] = ‘ect-timeline-styles’;
$exclude_list[] = ‘sg-btn-css’;
return $exclude_list;
}I tried both inserting it into the functions.php file and as a php string activated by snippet but nothing changes
Hello @ilgrizly,
If setting up the proper handles is not working then different handles should be excluded and interact with the files of the Events Shortcodes For The Events Calendar or something else is interfering.
I would suggest that you disable the combination and use the Code Snippets plugin to extract all handles of the scripts loaded on the page and put them under the filter in functions.php of your theme. You can enable the option from the plugin at that point and start commenting out each handle one by one to see when the combination won’t affect the desired script.
Please be advised that in the example you provided you have excluded the handles from getting minified. If you want to exclude them from getting combined you should use:
add_filter( 'sgo_css_combine_exclude', 'css_combine_exclude' ); function css_combine_exclude( $exclude_list ) { // Add the style handle to exclude list.$exclude_list[] = 'style-handle';$exclude_list[] = 'style-handle-2';return $exclude_list; }And for JS files:
add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' ); function js_combine_exclude( $exclude_list ) {$exclude_list[] = 'script-handle';$exclude_list[] = 'script-handle-2';return $exclude_list; }All filters can be found on this link:
https://www.siteground.com/tutorials/wordpress/speed-optimizer/custom-filters/
Then you will know the correct handles that should be excluded for the proper work of the plugin.
Best regards,
Georgi Ganchev
SiteGround.com
The topic ‘css e js’ is closed to new replies.