• Hi there, I’m curious if anyone has a copy/paste code that could be used in functions.php to only load the Theme My Login resources (like js files) on pages that use them? Such as by naming the IDs of pages that need them?

    I’m not a huge coder so any help here would be valuable.

    Also curious, would this affect the plugin’s functionality in any way?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    It is loaded everywhere because the widget/shortcode/template tag could be in use anywhere. With that said, sure you can dequeue the scripts/styles where you know you don’t need them.

    If you’re only using TML’s pages, it would be the most trivial:

    
    function maybe_dequeue_tml_assets() {
        if ( ! Theme_My_Login::get_object()->is_tml_page() ) {
            wp_dequeue_style( 'theme-my-login' );
            wp_dequeue_script( 'tml-themed-profiles' );
        }
    }
    add_action( 'template_redirect', 'maybe_dequeue_tml_assets' );
    
    Thread Starter joycegrace

    (@joycegrace)

    Thank you so much. I’m not much of a coder, so I’m curious, how would we do this if we wanted to use some simple conditional logic, like !is_home() for instance, or by specifying IDs of pages that shouldn’t use them?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Load Theme My Login resources only on pages that need them?’ is closed to new replies.