Let’s take a step back; before you disabled AO was it aggregating/ minfifying CSS/ JS? Or was the only problem with the fonts?
Hi,
Correct — Autoptimize was working as intended, combining CSS and JS, but font files were not served through CDN.
I did try to add the snippet suggested. Cleared all caches, but result was same.
I do have few more sites running off same server in pretty much same plugins configuration. They are working fine. So, I started to look at what may be different between sites. There are only two things that really come to mind — different themes and site in question is using non-standard WP_CONTENT_URL. Your FAQ suggests this may affect Autoptimize, so, I think, it is worth trying to fix this first.
Thank you for your help
Rudolf
the wp-content thing is unlikely the issue, as JS & CSS were aggregated/ minified OK .. can you share the URL of the site with the font-CDN-issue?
Hi,
I switched site back to using Autoptimize.
https://www.hatsfromoz.com.au
As you can see font files that are loaded through “automptimised” files are not CDNed.
Those, not loaded through autoptimize, are caught by bunnyCDN plugin and served through CDN.
Also, confirming following code is added to the site:
add_filter( ‘autoptimize_filter_css_fonts_cdn’, ‘__return_true’ );
Rudolf
-
This reply was modified 5 years, 1 month ago by
rudolfl.
OK,
I found the problem, but have no idea at the moment how to fix it.
For some reason, original site developers did a very strange thing — WordPress files are placed into directory /wordpress, while rest of the site is in directory /content. And here lies the problem!
/public_html
– /wordpress
— /wp-admin
– /content
Wordpress functions to get site url are correctly getting https://www.hatsfromoz.com.au/wordpress
And this is what Autoptimizer relies on to set AUTOPTIMIZE_WP_SITE_URL constant
But, in my case, this constant should be set to “https://www.hatsfromoz.com.au”
I temporarily “fixed” the problem by setting
define( ‘AUTOPTIMIZE_WP_SITE_URL’, “https://www.hatsfromoz.com.au” )
Is there a hook I can call before setup() function is run to set those constant in there?
Rudolf
-
This reply was modified 5 years, 1 month ago by
rudolfl.
I temporarily “fixed” the problem by setting
define( ‘AUTOPTIMIZE_WP_SITE_URL’, “https://www.hatsfromoz.com.au” )
as far as I’m concerned that is the fix; AO specifically checks if the constant is set to allow “others” to set it differently, just like you’re doing 🙂
Thanks,
I thought so too.
Could not do it in the theme.
Had to do it in plugin by hooking into ‘plugins_loaded’ at priority < 10 as this hook is used by Autoptimized at default priority and this action is aclled before theme is loaded.
Thank you again for looking into it.
Rudolf
ah, but typically constant are set in wp-config.php no? anyway, if you have it working another way why not 🙂