I have 20 static components from Plugins and Theme for some reason cannot be seen by a Caching plugin because of issues like WP_CONTENT_URL
instead of content_url()
. Some apparent old style of PHP? Because of issues like this the caching plugin cannot rewrite the URLs as a static resource, cache it and have it served as a CDN pull resource. Going through all of the plugins and rewrite them, that will be a waste as soon as there is an update the change is gone.
My need is to figure out how to redirect each time a .js is requested it obtains the file from a different location. Example:
This is the location of one of the culprit files:
wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js
I want it from here:
https://CDNHost.KXCDN.com/wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js
I could probably do this in htaccess but I don't want 20 or more 301 or 302 redirects on the site.
Can all of the 25 scripts be included on one or more. None of the scripts I need to move a render blocking. One of my problems with this is I don't know js worth a darn.
I don't know how to intercept the request for the script in the original location & have it forgotten while getting the new location.
Can the Fetch Loading be used?
fetchInject([
'https://CDNHoat.KXCDN.com/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js'
])
If I call the files as a preload:
<link rel="preload"
href="New-file-location" as="script"
This does nothing with the original script call.
I hope some one else may have figured out how to do this. Or just flat out would share their knowledge to get me squared away.
Thanks