WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Ricardo
    Member
    Posted 2 years 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
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

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

  3. Ricardo
    Member
    Posted 2 years 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 year 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
    NetWebLogic Support
    Plugin Author

    Posted 1 year 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)

  6. adaldesign
    Member
    Posted 1 year ago #

    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.

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    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.

  8. adaldesign
    Member
    Posted 1 year ago #

    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.

  9. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    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

  10. adaldesign
    Member
    Posted 1 year ago #

    Thanks Marcus, this plugin you suggested did the trick:

    Use Google Libraries

  11. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    didn't work for everyone, glad it did for you ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic