• Hi. I just wanted to check what the code is that stops this plugin loading on pages if it’s not being used. I have other block plugins that always seem to load on every page but want them to load only when being used. Respect to you and your design team.

    I’ll share this info with other plugin makers to hopefully help create a heap of nice block plugins for everyone. Hope I can help here time to time too if you need testers.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    You mean you want to disable the plugin where you don’t use blocks? If that’s the case unfortunately that’s not possible as all the Gutenberg plugins are coming to supercharge it and we can’t detect if a block is used or not on a particular page.

    Cheers,

    Thread Starter a4jp

    (@a4jpcom)

    Other plugins are doing it.

    Here is some sample code if you haven’t seen how to check for blocks.

    if ( has_block( 'video', $mypost ) && has_block( 'gallery', $mypost ) ) {
       // ...
    }

    I just couldn’t see any code like this in your plugin. Can you fix the plugin so it doesn’t load the files on pages it’s not used on?

    You could even look at the “Find My Blocks” plugin for coding ideas. It lists all the blocks on every page.

    This is not exactly what happens and not all other plugins are doing it, a minority in fact because in some configuration it may leads to styles or features not loaded (with some themes mainly because of the cache system that needs to be generated with a different version of the file on each page).

    Major plugins like WooCommerce are not doing it and there’s a reason for that, don’t you think?

    Is it good for optimization? yes and no depending of the theme and the cache, compression… you have. In the case of our plugin we loading 3 minified files including a custom CSS one.

    Do we deserve a bad review after coping this text and for that reason, that the real question here.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Where is the code that stops this plugin loading if it isn’t on a page?’ is closed to new replies.