Forums

Events Manager
[resolved] How to disable scripts? (5 posts)

  1. Ricardo
    Member
    Posted 5 months ago #

    I'm running EM 5.0rc1 over WP 3.3.

    By default, Events Manager loads all these scripts:

    jquery.js
    jquery.ui.core.min.js
    jquery.ui.widget.min.js
    jquery.ui.position.min.js
    events-manager.js

    and an extra inline JS code. I'm not using any of these scripts, at least not in the frontend, so I'd like to disable them in order to make the pages load faster.

    I already tried wp_dequeue_script unsuccessfully. Is there any other way to prevent all these scripts from loading?

    Thanks,

    Ricardo

    http://wordpress.org/extend/plugins/events-manager/

  2. Marcus
    Member
    Posted 5 months ago #

    wp_dequeue_script should work. Make sure you call it using the right action, e.g. init

  3. Ricardo
    Member
    Posted 5 months ago #

    My bad, it does work. I was only dequeuing the script, I had to also deregister it. Here's the code, in case anyone else needs it:

    function disable_scripts () {
    	if ( !is_front_page() ) {
    		wp_dequeue_script('jquery');
    		wp_deregister_script('jquery');
    	}
    }
    add_action('wp_enqueue_scripts','disable_scripts');

    Hooking it to wp_enqueue_scripts instead of init allows to use conditional tags like the one in the example.

    Thanks!

  4. smarru
    Member
    Posted 1 week ago #

    Hi,

    Is there anyway to disable the following dependencies without disabling events-manager.js. Below dependencies are loaded in all pages. I think the below files are needed only in events calendar page. On all other pages we don't need the below dependencies. Only events-manager.js will suffice.
    jquery.ui.core
    jquery.ui.widget
    jquery.ui.position
    jquery-ui-sortable
    jquery-ui-datepicker
    jquery-ui-autocomplete

    I saw below statement in events-manager.php but I dont want to modify this in core plugins files.
    wp_enqueue_script('events-manager', plugins_url('includes/js/events-manager.js',__FILE__), array('jquery', 'jquery-ui-core','jquery-ui-widget','jquery-ui-position','jquery-ui-sortable','jquery-ui-datepicker','jquery-ui-autocomplete'));

    Can you please help me?

    Thank you,
    Srilatha

  5. Marcus
    Member
    Posted 2 days ago #

    not adviseable but possible, you'd have to remove the script e.g.

    wp_dequeue_script('events-manager');

    and then re-enqueue it with a code similar what you pasted, but you need to check what page you're loading so if it's needed you do load these scripts (e.g. search page, bookings, submit events pages)

Reply

You must log in to post.

About this Plugin

About this Topic