Conditionally replace local jQuery with asynchronous version

In some cases, we recommend loading jQuery asynchronously, rather than deferring it. This means it loads as soon as it can, but is not render-blocking.

We typically recommend this when:

  • You have social counts enabled, particularly through Social Warfare
  • You’re running ads, including a video player, through AdThrive

We sometimes run into issues with this, as asynchronous jQuery will sometimes load too later and page functionality will not work as expected. It’s an intermittent issue.

In cases where using asynchronous jQuery isn’t ideal, our options become:

  1. Sacrifice the broken functionality (remove and/or replace the plugin with something that works)
  2. Leave jQuery render-blocking
  3. “Aggregate inline JS” (if we’re using Autoptimize; see this article on whether enabling this setting is a good idea)