Hi @amauric, @marou10,
The issue is with the way that tarteaucitron.js determines its own URL. It uses a technique like this:
var scripts = document.getElementsByTagName("script");
var url = scripts[scripts.length - 1].src;
This will get the URL of the last script on the page. Normally, this works fine, because the last script in the DOM is the one that is currently executing (the rest of the page has not yet been parsed).
But when using PhastPress this does not work. Before scripts are executed, the entire page is loaded, so the last script will always be the same, and not the one that is currently executing.
Instead of using this technique, I would recommend doing this:
var url = document.currentScript.src
This won’t work in IE, so you might do this:
var url = (document.currentScript || scripts[scripts.length - 1]).src
For the current situation you may define the variable tarteaucitronForceCDN
to tell tarteaucitron.js where to find its resources. You need to do this before loading the tarteaucitron.js.
You can do this by adding this code to your plugin:
add_action('wp_print_scripts', function () {
printf(
"<script>tarteaucitronForceCDN=%s</script>\n",
json_encode("https://cdn.jsdelivr.net/gh/AmauriC/[email protected]/")
);
});
You may replace the URL with a variable so you don’t repeat it when loading the script itself and it’s easier to update the version, but that’s up to you.
Hope this helps, and good luck!
–Albert