• Resolved allm

    (@realblueorange)


    @cubecolour
    I see that you made an adjustment in version 1.0.2: enqueue plugin js only when needed.

    This seems like a good idea, but I have a case where the page with a tabby is output to a transient (shortcodes expanded) each day, and the transient gets output to the screen. It seems that the js is not enqueued on that page.

    Any ideas how I can fix your enhancement for that specific page?

    https://www.ads-software.com/plugins/tabby-responsive-tabs/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author cubecolour

    (@numeeja)

    Does deleting & regenerating the transient make any difference?

    If not, you can to go back to version 1.0.1 from https://www.ads-software.com/plugins/tabby-responsive-tabs/developers/ – it might be worth changing the version number in the tabby-responsive-tabs.php to 9999 so it doesn’t update in future.

    Apart from the fix to enqueue the js only when needed, the only other changes were in the css.

    Thread Starter allm

    (@realblueorange)

    @cubecolour:

    Thanks for your quick reply.

    Deleting & regenerating makes no difference. I guess the plugin only enqueues the js when the tabby shortcode is on the page. In my case the shortcode isn’t there anymore (has been do_shortcode’d before storing in the transient), but the js still needs enqueueing on that page for the tabs to appear.

    I don’t think it is a good idea to go back to 1.0.1 and never update again…

    I guess that not enqueueing the js when the shortcode is not on the page is a good idea in more than 99% of the cases. My case is just in that 1% category.

    I’ll figure out a way to also enqueue the js on that particular page. I’ll have a look at your code and implement some sort of workaround.

    Plugin Author cubecolour

    (@numeeja)

    Try adding the following to your child theme’s functions.php or custom functions plugin if you’re using one

    function cc_tabby_js() {
    	wp_enqueue_script( 'tabby', plugins_url('/tabby-responsive-tabs/js/tabby.js'), array('jquery'), '1.0.0', true );
    }
    add_action('wp_enqueue_scripts', 'cc_tabby_js');
    Thread Starter allm

    (@realblueorange)

    @cubecolour
    Thanks for your suggestion. I added it to my child theme and everything worked again. Then I tried modifying it so it only loaded on the one page where it is needed.

    Furthermore I checked the source code of your plugin to see if I could come up with an even more generic solution.

    In the process I suddenly found out that after deleting the transient & regenerating it it should all work, just as you suggested. And it did. I thought I had tried that before I reacted earlier, but shame on me I apparently did not.

    So after all, I do not need to change anything. I just need to be careful when you come out with a new version of the plugin. In that case I need to regenerate the transient (which I already do once a day automatically).

    So, everything is solved on my end. I’ll set this thread to resolved.

    Thanks for looking into this. Really appreciate it.
    I already gave a 5-star review. If I could I would do it again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘enqueue plugin js only when needed’ is closed to new replies.