osompress / simple-social-icons

Plugin: Simple Social Icons
62 stars 33 forks source link

Only enqueue scripts/styles if a widget is actually on the page #99

Open JiveDig opened 5 years ago

JiveDig commented 5 years ago

I have SSI installed on a site but when I dump all my scripts via:

add_action( 'genesis_before_loop', function() {
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }
    global $wp_scripts;
    foreach ( $wp_scripts->queue as $handle ) {
        echo '<pre>';
        print_r( $handle );
        echo '</pre>';
    }
});

I see svg-x-use in the list.

After looking in dev tools I see the CSS is loaded too.

Screenshot 2019-07-18 15 56 20

It would be great to check for widgets before enqueueing too. May be easier said than done, as I haven't attempted that yet.