This is to avoid loading other assets and scripts that are not needed for certain content types, pages, etc.

I have seen this in wordpress, there are performance plugins that allow you to selectively choose which scripts and assets to load.

I can't find any module on Drupal that allows this, just wondering if any of you know about some, or what approach could we use to achieve this.

  • 1
    This question is a little backwards in terms of Drupal. in Drupal, assets are attached to the element to which they belong, and are only included if that element is part of the page. The exception is when they are added in the .info file of a module or theme, which will load them on all pages. How are you currently attaching the assets now? – Jaypan Jun 3 '20 at 1:45
  • 1
    I should add though, that you can look at the Advagg module (dgo.to/advagg) for CSS/JS optimization. I use it on all sites. It increases performance and aggregation of assets beyond what Drupal core does. – Jaypan Jun 3 '20 at 1:55

Your Answer

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

Browse other questions tagged or ask your own question.