I’ve since taken it down (the CSP) but what I had was similar to this:
Header set Content-Security-Policy “default-src ‘self’; “script-src ‘self’ cdn.for-some-js.com; (and so on adding “style-src” and such)
What happens is a bunch of errors happen in the console and you keep adding the external URIs to permit them running on the site. But for anything running on the main domain. However, inline JS will not run until you modify the CSP to something like such:
Header set Content-Security-Policy “default-src ‘self’; “script-src ‘self’ cdn.for-some-js.com ‘unsafe-inline’;(…)
And while the JS might be safe, the fact you have to use ‘unsafe-inline’ is a security concern.
As for the algolia plugin: I moved the php files to my theme directory/algolia
inside of that I put the 2 php files. I then I made a inc/js folder. I removed the JS between <script>…</script> and moved them into algolia/inc/js
This is my functions.php
// Load Algolia Autocomplete JS
add_action( 'wp_enqueue_scripts', 'bo_add_algolia_autocomplete', 999 );
function bo_add_algolia_autocomplete() {
wp_register_script('bo-autocomplete', get_stylesheet_directory_uri() . '/algolia/js/algolia-autocomplete.js', array(),'1.1', true);
wp_enqueue_script('bo-autocomplete');
}