• Resolved jlongbrake

    (@jlongbrake)


    It would be nice if this plugin would only load its scripts and styles on pages where it is being used. I was able to do this for my site by removing the call to “add_public_scripts” from class-ps-ajax.php and adding it to class-ps-public.php and calling that function from within “render_shortcode”. I don’t know if this will cover all use cases, but works for me. Thought I’d suggest it and see if it’s a feature that could be added.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jlongbrake

    (@jlongbrake)

    Just realized my fix broke some things, like the YouTube embed block lol. Going for another option now. Would still be a nice feature to add to the plugin.

    Plugin Author patrickposner

    (@patrickposner)

    Hey @jlongbrake,

    that’s a really good suggestion and will definitely find its way into Passster soon.

    As you’ve already experienced, it’s not as easy as enqueuing the scripts within render_shortcode because of the different contexts where these are needed:

    • within a block if you use the area block
    • within the page if you use page/global protection
    • within the shortcode (that’s the easy one)
    • within ajax to render embeds and third party shortcodes

    Nevertheless, I will implement that as I deeply care about performance, but that will involve quite a lot of iteration and testing ??

    Best regards,
    Patrick

    Thread Starter jlongbrake

    (@jlongbrake)

    Turns out I did get the shortcode (easy) one working, but the YouTube thing was a separate issue. I knew there would be more use cases that needed addressed which is why I wanted to suggest it to you. Thanks for taking a deeper look into it and I look forward to this future release ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Scripts and Stylesheets loading when plugin not in use’ is closed to new replies.