Is it possible to delay external libraries with it?

I have a Drupal commerce website and my payment solution loads an external library on every pages.
I only need it on my product's pages and Lighthouse complains a lot about it!

Cheers

Comments

mchamps created an issue. See original summary.

vdsh’s picture

Sure! You can also remove external javascript files if added through any of the standard Drupal mechanisms. Eg, you can remove (or delay) //cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js

What I suggest you do is create 2 strategies, a default one with this external js file removed and another one where it is not (maybe delayed to improve performance?)

Then use rules https://www.drupal.org/project/rules to select this other strategy based on conditions (eg: only on product pages)

Hope it helps (please close this ticket if it did)

vdsh’s picture

Status: Active » Fixed

I set the ticket as Fixed as no replies, feel free to reopen if needed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.