Tip 5 revisited: Dynamically add plugins

Performance tip 5 revisited – dynamically add plugins needed to serve the content.

For Tip 5: Remove plugins you don’t use I used oik-unloader to dynamically deactivate plugins to improve the performance of a specific URL. While this method can improve the performance of selected URLs, the rest of the site will still be affected by activated plugins.

Another option is to deactivate plugins until we know they’re needed.

These plugins were used to produce the 3 pages with poor performance.

  • Simple Owl Carousel – for the carousel
  • A dozen or so of the top 30 plugins by most downloaded:
    • Akismet – not needed as no comments allowed
    • All-in-one-SEO
    • All in one WP Migration
    • Contact Form 7
    • Elementor – used on the Elementor page
    • Google Site Kit
    • Jetpack – for related posts and GDPR widget
    • NextGEN gallery – for the gallery on each page
    • The Events Calendar
    • UpdraftPlus
    • WooCommerce
    • Wordfence
    • WordPress ( Yoast ) SEO
    • WP Forms Lite

Six of these plugins were only used to intentionally slow the site down. For performance scores I can happily do without most of them.

Implementation

  • Using oik-loader add these plugins to the list of dependent plugins for the selected URLs.
  • Deactivate each of the plugins.

When the URL is visited the oik-loader plugin dynamically adds the dependent plugins to the list of active plugins. WordPress loads these plugins therefore enabling the required functionality.

The configuration includes to post ID of each post so that the plugins can be loaded when invoking the editor. This solution may not work for all plugins.

References


Summary file