0

I help look after a site which uses $settings['file_public_base_url'] to serve files from a different subdomain on the frontend, but on the backend (admin paths like node/add and node/edit) this causes our JS to be loaded with absolute rather than relative URLs which seems to cause an issue with JS loaded via AJAX not executing correctly. There are no JS errors in my devtools console, but I suspect the cause is that the JS is being loaded from differing subdomains, as turning AdvAgg and core's JS aggregation off makes the JS files load via relative paths and function as intended.

Without any errors showing in my console or server logs I'm not sure I'm going to be able to get to the bottom of the AJAX issue, so for now a compromise seems to be to turn off aggregation for admin and content editing routes.

What would be the best way to do that? I know I can set $config['system.performance']['js']['preprocess'] = FALSE; and presumably a similar config key for AdvAgg's own setting (we have AdvAgg set to optimise/compress JS, so even with system.performance.js.preprocess turned off AdvAgg will still manage the files and use absolute paths to include them. Can config settings be altered on a per route/path basis?

  • Have you tried the Advanced CSS/JS Aggregation permission and/or ?advagg=0 ? I believe they are disabling aggregation. – GiorgosK Mar 23 at 16:32
  • HI @GiorgosK, as well as disabling AdvAgg I also need to disable Core's aggregation too, so I don't think the permission or query string based approach is enough. – Phil Mar 24 at 17:21
0

So, the issue I describe in my question is this Drupal Core issue: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS

So, my solution wasn't to disable the aggregation, but to apply the latest patch provided in the issue on Drupal.org

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.