WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Events Manager] How to disable scripts?

[Resolved] [Plugin: Events Manager] How to disable scripts?

  • 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/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Marcus

    @netweblogic

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

    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!

    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

    Plugin Author Marcus

    @netweblogic

    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)

    I’ve tried to implement the final result of what these posts suggest but ‘events-manager’ wont’ load:

    add_action('wp_enqueue_scripts', 'child_enqueue_js', 20);
    function child_enqueue_js() { 
    
    	wp_dequeue_script('events-manager');
    
    	$eventsScripts = array(
    		'jquery-ui-draggable',
    		'jquery-ui-position',
    		'jquery-ui-widget',
    		'jquery-ui-core',
    		'jquery-ui-mouse',
    		'jquery-ui-sortable',
    		'jquery-ui-datepicker',
    		'jquery-ui-autocomplete',
    		'jquery-ui-resizable',
    		'jquery-ui-button',
    		'jquery-ui-dialogue'
    		);
    	wp_dequeue_script( $eventsScripts );
    	wp_deregister_script( $eventsScripts );
    
    	wp_enqueue_script('events-manager', plugins_url('includes/js/events-manager.js', 'events-manager'), 'jquery');
    }

    The above code successfully removed the dependencies from being loaded, but it didn’t bring the events-manager.js back.

    Plugin Author Marcus

    @netweblogic

    Since EM depends on those scripts, it won’t load if you deregister them.

    I’ve been using “Use Google Libraries” – http://wordpress.org/extend/plugins/use-google-libraries/ and it may be of interest to you as instead of loading seperate files it loads one jquery ui library with all the dependencies, and from the Google CDN.

    Thanks for the reply Marcus.

    To help you understand, the KenBurns Plugin I’m using already enqueued the following: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js

    So I’m trying to remove redundant scripts as this seems to be causing conflicts.

    I’m going to try de-registering the events manager script altogether and reregistering it.

    Plugin Author Marcus

    @netweblogic

    The problem with that is you’re enqueuing a version WP isn’t using yet. Whilst our JS should work with later versions of jQuery UI, I’ve seen situations where plugins load the jquery-ui script ALONG with the ones loaded by WP, causing even more problems.

    I’ve suggested this to someone today, try the plugin above and see if it resets all the jQuery inclusions so it includes one jQuery library, once, and from the Google CDN

    Thanks Marcus, this plugin you suggested did the trick:

    Use Google Libraries

    Plugin Author Marcus

    @netweblogic

    didn’t work for everyone, glad it did for you 😉

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] [Plugin: Events Manager] How to disable scripts?’ is closed to new replies.