Removing Scripts/Styles on pages they shouldn’t be loading

Home Forums Calendar Products Events Calendar PRO Removing Scripts/Styles on pages they shouldn’t be loading

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1091145
    Allen Presher
    Participant

    Greetings,

    I’d like a function to dequeue all scripts/styles related to the events calendar on all pages but the Calendar and individual event listings. I had such a function before, but it seems the events calendar is loading yet more assets onto pages it ought not to, and so I’ve returned looking for a solution again.

    There ought to be an option in the plugin to disable loading event calendar assets on pages other than what we approve. This option should never break going forwards. When we deploy The Events Calendar to many client sites, spending significant time optimizing those sites, only to months later return to these sites to find that stylesheets and javascript files we did not approve are now being loaded on the HOMEPAGE, and that a javascript file enqueued in the header (where it should never be) also forced the jQuery library we had moved to the footer back to the header where it blocks rendering, that is an outrage. Not only do we need a solution to this, now we have to go back and deploy that solution to every effected website.

    Please consider the pain this causes developers. I look forwards to hearing a solution, and I hope that solution can be made a permanent fixture so that we may continue deploying the Events Calendar to dozens more sites going into the future.

    The current assets being inserted without my consent bogging down my homepage are as follows:


    <link rel='stylesheet' id='widget-this-week-pro-style-css' href='http://site.com/wp-content/plugins/theeventscalendar.compu_request_pluginevents-calendar-proversion4.1pu_get_download1pue_active_version4.0-h3e2e3/src/resources/css/widget-this-week-full.css' type='text/css' media='all' />

    <link rel='styleshee
    t' id='tribe_events-widget-this-week-pro-style-css' href='http://site.com/wp-content/plugins/theeventscalendar.compu_request_pluginevents-calendar-proversion4.1pu_get_download1pue_active_version4.0-h3e2e3/src/resources/css/widget-this-week-theme.min.css' type='text/css' media='all' />
    <script type='text/javascript'>

    /* <![CDATA[ */
    var tribe_this_week = {"ajaxurl":"http:\/\/site.com\/wp-admin\/admin-ajax.php"};
    /* ]]> */
    </script>

    <script type='text/javascript' src='http://site.com/wp-content/plugins/theeventscalendar.compu_request_pluginevents-calendar-proversion4.1pu_get_download1pue_active_version4.0-h3e2e3/src/resources/js/widget-this-week.min.js'></script>

    #1091241
    George
    Participant

    Hi @Stratejusinc,

    I agree very much that our plugins should not load files where they’re not needed. We’ve done a decent job of this in the past, but as the plugin’s grown and changed this seems to have gotten out of hand again.

    I have just created a high-priority bug ticket for this and we can hopefully see an official fix for this in the coming weeks.

    I do not have a specific ETA for when that fix will arrive, unfortunately; also, while I will try to provide a code-based solution now, before the official release of a fix, I cannot guarantee that we’ll be able to do that here. It’s a complicated code customization to make to preserve all Calendar functionality completely, but then selectively ensure it doesn’t load on non-Calendar-feature pages.

    That being said, here is an attempt to do that:

    add_action( 'init', 'try_to_disable_tribe_scripts_on_home' );

    function try_to_disable_tribe_scripts_on_home() {
    if ( is_home() ) {
    remove_action( 'wp_enqueue_scripts', array( 'Tribe__Events__Pro__This_Week', 'styles_and_scripts' ) );
    }
    }

    Try adding this to your theme’s functions.php file.

    I hope this helps temporarily, while we work on an outright and official fix in our plugins.

    Thank you,
    George

    #1097435
    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.

    #1136784
    Geoff
    Member

    Hey there, @stratejusinc!

    We wanted to follow-up to let you know that we were able to patch this up in The Events Calendar and Events Calendar PRO 4.2.2, which is now available to download and install if you haven’t done so already.

    Please do be sure to check out our release notes for a full overview of what’s new in the release and feel free to let us know if you run into this or any other issues after the update.

    Thanks so much for your patience while we worked on this!

    Cheers,
    Geoff

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Removing Scripts/Styles on pages they shouldn’t be loading’ is closed to new replies.