All from one system really helps serious developers on the WordPress CMS.
I am currently using the Amazon Auto Links plugin and have noticed a significant performance issue. The plugin’s CSS and JavaScript files are being loaded on all pages of my site, even when the [amazon_auto_links]
shortcode is not present. This is causing unnecessary resource usage and a drop in page speed.
To optimize my website’s performance, I want to ensure that these assets are loaded only on pages or posts where the [amazon_auto_links]
shortcode is actually used.
Here is what I have tried so far:
/**
* Caricamento condizionale degli asset di Amazon Auto Links.
* Carica i file CSS e JS solo se lo shortcode [amazon_auto_links] è presente nella pagina o nel post.
*/
function conditional_amazon_auto_links_assets() {
global $post;
// Controlla se il contenuto contiene lo shortcode [amazon_auto_links]
if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'amazon_auto_links' ) ) {
// Carica i file CSS necessari
wp_enqueue_style(
'amazon-auto-links-list-style',
plugins_url( 'amazon-auto-links/template/list/style.min.css' ),
array(),
'1.4.1'
);
wp_enqueue_style(
'amazon-auto-links-common-style',
plugins_url( 'amazon-auto-links/template/_common/style.min.css' ),
array(),
'5.4.3'
);
// Carica i file JS necessari
wp_enqueue_script(
'amazon-auto-links-pointer-tooltip',
plugins_url( 'amazon-auto-links/include/core/main/asset/js/pointer-tooltip.min.js' ),
array( 'jquery' ),
null,
true
);
wp_enqueue_script(
'amazon-auto-links-product-tooltip',
plugins_url( 'amazon-auto-links/template/_common/js/product-tooltip.min.js' ),
array( 'jquery' ),
'1.0.0',
true
);
wp_enqueue_script(
'amazon-auto-links-ajax-unit-loading',
plugins_url( 'amazon-auto-links/include/core/component/unit/asset/js/ajax-unit-loading.min.js' ),
array( 'jquery' ),
'6.7.1',
true
);
wp_enqueue_script(
'amazon-auto-links-image-preview',
plugins_url( 'amazon-auto-links/template/_common/js/product-image-preview.min.js' ),
array( 'jquery' ),
'1.0.0',
true
);
wp_enqueue_script(
'amazon-auto-links-now-retrieving-updater',
plugins_url( 'amazon-auto-links/include/core/component/unit/asset/js/now-retrieving-updater.min.js' ),
array( 'jquery' ),
'6.7.1',
true
);
}
}
add_action( 'wp_enqueue_scripts', 'conditional_amazon_auto_links_assets' );
Unfortunately, this solution does not work. The CSS and JS files from Amazon Auto Links are still being loaded globally, regardless of whether the [amazon_auto_links]
shortcode is present or not.Questions:
[amazon_auto_links]
shortcode?This issue is negatively impacting my site’s speed and unnecessarily consuming resources. Any guidance or recommendations would be greatly appreciated.
Thank you in advance for your support!
Luca Tacchetti
]]>The sample url: https://mywebsite.com/pxpdflip_stream/204, (where 204 will vary)
The url redirection is defined in the htaccess as:
RewriteRule ^pxpdflip_stream/([^/]+)[/]?$ /wp-content/themes/mytheme/lib/FlipBook/1.0/lib/streamfile.php?ao=$1 [QSA,L]
So far, I have added an entry like this in the ‘Never minify the following pages’ section of ‘Performance > Minify > Advanced’ :
/pxpdflip_stream/.*
But it is not working. The page outputs a 500 error. Once the plugin is disabled, it works fine Can you please help?
PS: I want to exclude these pages from all types of caching.
]]>file_get_contents(/home/deb45628n2/domains/chocoladeverkopers.nl/public_html/chocolade/wp-content/cache/minify/864fa/default.include.js.id_meta): Failed to open stream: No such file or directory+
file_get_contents(/home/deb45628n2/domains/chocoladeverkopers.nl/public_html/chocolade/wp-content/cache/minify/864fa/default.include.css.id_meta): Failed to open stream: No such file or directory
if i disable minify it is ok. i use minify and page cache (disk) and object cache (redis), but not sure what to test – i have tried disabling several other plugins as well but no luck there. Maybe it’s possible to point me in the right direction..
Any ideas what I could do about this?
Thanks for your help.
]]>auto
is not a max-width
value : auto1Unknown pseudo-element or pseudo-class :-ms-lang
1Unknown pseudo-element or pseudo-class :-ms-lang
1.wpdiscuz_select""
is not a text-overflow
value : “”1Unknown pseudo-element or pseudo-class :-ms-lang
1Unknown pseudo-element or pseudo-class :-ms-lang
1Unknown pseudo-element or pseudo-class :-ms-lang
1Unknown pseudo-element or pseudo-class :-ms-lang
1Unknown pseudo-element or pseudo-class :-ms-lang
1Unknown pseudo-element or pseudo-class :-ms-lang
1Unknown pseudo-element or pseudo-class :-ms-lang
1#wpdcom.wpd-layout-3 .wpd-comment .wpd-comment-footer .wpd-vote-up, #wpdcom.wpd-layout-3 .wpd-comment .wpd-comment-footer .wpd-vote-downValue Error : background-color none
is not a background-color
value : noneURI : https://julkamalecka.pl/wp-content/cache/background-css/julkamalecka.pl/wp-content/plugins/wpdiscuz/assets/css/wpdiscuz-combo.min.css?ver=6.3.2&wpr_t=16990083128#cboxOverlayParse Error = 90)