1

On my d8 site I have AdvAgg CSS/JS Validator, AdvAgg Minify CSS, AdvAgg Minify JavaScript, AdvAgg Modifier and Advanced CSS/JS Aggregation enabled.

I have standard settings used in the AdvAgg config. For JS specifically, I am using JSmin + and delivering gzip'd assets.

Under admin/config/development/performance, if Aggregate JavaScript files is unchecked, my JS files are delivered from the js/optimized/ folder and JS runs correctly. When I check Aggregate JavaScript files on, assets are now placed from /js/ and javascript is broken.

Further, when I paste the optimized file name in admin/config/development/performance/advagg/info, for e.g.: js_nrTZ3IQttmDSsRueLl0pyxRvunHefp0r1WyIh5cFezg.js AdvAgg cannot find the file (but it can when aggregation is turned off).

Perhaps this all makes sense since aggregating JS files is a Drupal feature, but I've been down every related question/comment thread on google (changing .htaccess, adding tmp folders, changing folder permissions etc) and cannot find a fix for: AdvAgg is on with standard config, Aggregating JS files is on and javascript is broken. There are no obvious errors in the javascript console or drupal error log either.

EDIT

Here is what the file paths look like with aggregation on: <script src="/sites/energyforum/files/js/js_tvBcOK6c8zbgb2_h2fxvH7fqhBBhGUnfOtQvWyXg1AM.js"></script>

The files are actually there, e.g.: enter image description here

Here is what they look like with aggregation turned off

<script src="/sites/energyforum/files/js/optimized/js_dxIVcwvQ00owLGoUGPTfRYXU-T5rnj8Xi0cXfb3Kn58.0EvW5goc0mi1CLAZ226j56yYkdNjFXiaCYoOaoBMbKg.js?v=3.2.1"></script>

And, of course, there are many more of them (and javascript works)

4
  • Broken as in 404, or broken as in there are JS errors in the console? Its possible that there is a statement in the JS source that corrupts the output?
    – Kevin
    Commented Sep 25, 2019 at 18:37
  • broken as in components arent working. For e.g. the site uses kenwheeler.github.io/slick to manage a carousel; when Aggregate JS Files is turned off it works fine, but when its on this component is broken. The only noteworthy JS error is: Uncaught TypeError: a.indexOf is not a function at r.fn.init.r.fn.load
    – plambre
    Commented Sep 25, 2019 at 18:44
  • Is the aggregated file actually there (i.e. was it generated at all)? Also, are you using S3 or a CDN? Often times, we've had issues where Drupal couldn't write to S3 but Drupal knew about the file and tried to serve it. Or Drupal could write to S3 but the CDN would return 404 because it wasn't aware of the new file.
    – Joseph
    Commented Sep 26, 2019 at 2:17
  • Added an edit @joesph, this result is occurring locally for me so CDN's shouldn't be a problem.
    – plambre
    Commented Sep 26, 2019 at 15:29

1 Answer 1

1

This is commonly a result of loading theme javascript before it's dependencies.

If your theme lists multiple external js dependencies, or just has multiple custo. Javascript files, you may need to assign weights to establish a load order. Refer to https://www.drupal.org/docs/8/theming/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-theme

Likewise, if your theme depends on other javascript provided by other modules, be sure to list those dependencies in your theme.info.yml file.

After making any of the above changes, clear Drupal caches with aggregation turned on and retest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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