WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
JavaScript Disaster (5 posts)

3 stars
  1. danielmichel
    Member
    Posted 1 year ago #

    'Good' plug-in, but the JavaScript is set to load on EVERY page on the website. How about something like `function public_enqueue() {
    if( is_page('events') ) { //Only load on the page "events"
    //Scripts
    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','jquery-ui-dialog')); //jQuery will load as dependency
    //Styles
    wp_enqueue_style('events-manager', plugins_url('includes/css/events_manager.css',__FILE__)); //main css
    }
    }`

  2. dearjudy
    Member
    Posted 1 year ago #

    Good point.

  3. David Radovanovic
    Member
    Posted 1 year ago #

    Ditto here

  4. gatesjr03
    Member
    Posted 1 year ago #

    EDIT FOR danielmichel

    This is a 'Good' plug-in, but the JavaScript is set to load on EVERY page on the website.
    How about something like:

    function public_enqueue() {
      if( is_page('events') ) { //Only load on the page "events"
        //Scripts - NOTE: jQuery will load as dependency
        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',
                            'jquery-ui-dialog'
                         ));
    
        //Styles - main css
        wp_enqueue_style('events-manager',
                         plugins_url('includes/css/events_manager.css',__FILE__)
                        );
      }
    }
  5. Rocio Valdivia
    Member
    Posted 1 year ago #

    I agree, good point.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.