Possible to load Event Calendar CSS and JavaScripts ONLY when needed?

Home Forums Calendar Products Events Calendar PRO Possible to load Event Calendar CSS and JavaScripts ONLY when needed?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #21670
    Christian
    Participant

    When the Event Calendar plug-in is active, its CSS and JavaScripts are embedded in the header on every single page of the same site. Also on pages that don’t show any calendar information.

    Is there an easy way to limit this on the pages where these are actually needed (start page, event grid, list and single view pages)? Or also a complex way if necessary (maybe de-registering in functions.php? But how?)
    Any help appreciated…

    #21708
    Jonah
    Participant

    Hi Christian,

    This should get you on your way:

    function remove_styles() {
    if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
    //wp_dequeue_style( 'tribe_events-admin-ui' );
    wp_dequeue_style( 'tribe-events-mini-calendar' );
    wp_dequeue_style( 'tribe-events-calendar-style' );
    }
    }
    add_action('wp_print_styles','remove_styles',1);

    function remove_scripts() {
    if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
    wp_dequeue_script( 'tribe-events-calendar-script' );
    wp_dequeue_script( 'tribe-events-pjax' );
    wp_dequeue_script( 'tribe-events-mini-calendar' );
    wp_dequeue_script( 'jquery-ecp-plugins' );
    wp_dequeue_script( 'chosen-jquery' );
    wp_dequeue_script( 'tribe_events-admin' );
    }
    }
    add_action('wp_print_scripts','remove_scripts',1);

    Put that in your theme’s functions.php file and add/remove whatever you want/don’t want. You can also use these conditional wrappers to further customize this: https://gist.github.com/2415009

    I hope that helps!

    – Jonah

    #977279
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Possible to load Event Calendar CSS and JavaScripts ONLY when needed?’ is closed to new replies.