When I ran Algolia Search with WP Rocket I bumped into WP Rocket Algolia Search Conflict. With JavaScript Minification turned on I got several errors
JavaScript Errors
I got this error:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (head.js.map, line 0)
as well as these:
Uncaught ReferenceError: algoliasearch is not defined at HTMLDocument.<anonymous> ((index):94) at i (a9b476399a1ace75e81cb940be005dd2.js:2) at Object.fireWith [as resolveWith] (a9b476399a1ace75e81cb940be005dd2.js:2) at Function.ready (a9b476399a1ace75e81cb940be005dd2.js:2) at HTMLDocument.K (a9b476399a1ace75e81cb940be005dd2.js:2) (anonymous) @ (index):94 i @ a9b476399a1ace75e81cb940be005dd2.js:2 fireWith @ a9b476399a1ace75e81cb940be005dd2.js:2 ready @ a9b476399a1ace75e81cb940be005dd2.js:2 K @ a9b476399a1ace75e81cb940be005dd2.js:2
and these:
SyntaxError: expected expression, got '<' ReferenceError: algoliaAutocomplete is not defined[Learn More] wpvilla.in:131:9
The latter two were the real culprit as a soon as these showed up the site would not load properly anymore. The files causing the issue seemed to be:
https://wpvilla.in/wp-content/plugins/search-by-algolia-instant-relevant-results/js/algoliasearch/algoliasearch.jquery.min.js?ver=2.8.1 https://wpvilla.in/wp-content/plugins/search-by-algolia-instant-relevant-results/js/autocomplete.js/autocomplete.min.js?ver=2.8.1
WP Rocket JavaScript Exclusion
But I could no longer find a way to exclude these to make the error go away. Only CSS files could be excluded with the latest WP Rocket version it seemed:
This until I was reminded by WP Rocket you have to have JavaScript minification turned on to see this box. Then we added the Algolia general script and autocomplete script we found. This however clearly was not enough as we still had the same issues.
Solution
Solution given by WP Rocket for the site not loading with Algolia JS minified in the end was to add this to exclude all Algolia JS:
/wp-content/plugins/search-by-algolia-instant-relevant-results/(.*).js
So that means we probably somehow missed a script besides the ones I mentioned and this one was not excluded. It is now. Happy to have this work though! Again I would prefer to go without the inline script added by Algolia, but to solve that more time would be needed.