who to exclude GD js script from same pages

This topic contains 3 replies, has 3 voices, and was last updated by  Kiran 6 years, 5 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #406428

    filisara
    Buyer
    Post count: 4

    Hi team!
    I searched some info on th forum posts but I didn’t find anything about this thing.
    I saw that all GD scripts are loaded on all pages of my site, also when there aren’t necessary because there aren’t any GD information.
    To speed load pages I would like to remove js execute except for “places” pages. there is a workaround?

    many thanks!
    SF

    #406430

    Alex Rollin
    Moderator
    Post count: 27815

    Hello!

    You could make a plugin to do that. Here’s a page about some resources to get you started.

    https://css-tricks.com/taking-control-cssjs-wordpress-plugins-load/

    GD doesn’t provide settings or scripts.

    Your plugin could ‘sense’ which pages are created by GD based on your permalinks settings and the prefix ‘places’.

    By the way, we provide support here in the forum for the normal use of the core plugin.

    Thanks

    #406441

    filisara
    Buyer
    Post count: 4

    Hi Alex,
    thanks for the information!

    I thought something like your reply 🙂

    I found a lot of handles for GD, could you please let me know if this list is corretc?

    geodirectory-script
    geodirectory-jquery-flexslider-js
    geodirectory-lightbox-jquery
    geodirectory-jquery-simplemodal
    google-maps-api
    geodirectory-g-overlappingmarker-script
    geodirectory-leaflet-script
    geodirectory-leaflet-geo-script
    geodirectory-leaflet-routing-script
    geodirectory-o-overlappingmarker-script
    geodirectory-goMap-script
    geodirectory-choose-ajax
    geodirectory-jquery-ui-timepicker-js
    geodirectory-plupload-script
    geodirectory-listing-validation-script
    geodirectory-post-custom-js
    geodir-barrating-js
    geodir-jRating-js
    geodir-on-document-load
    google-geometa

    thanks!
    SF

    #406458

    Kiran
    Moderator
    Post count: 7069

    Hi SF,

    Yes, your list covers all the scripts loaded by GeoDirectory core, but Addons use GD Core JS plus additional files.

    In GD core most of the scripts and styles are loaded via geodir_templates_scripts() and geodir_templates_styles() functions. You can use the following to skip loading of GD Core scripts.

    
    
    remove_action( 'wp_enqueue_scripts', 'geodir_templates_scripts' );
    remove_action( 'wp_enqueue_scripts', 'geodir_templates_styles', 8 );

    geodir_is_geodir_page() is used to identify the GD page

    Here’s a Snippet that will execute only on GD Pages:

    
    
    
    add_action( 'wp', 'wpdocs_dequeue_script', 100 );
    function wpdocs_dequeue_script() {
        if (!geodir_is_geodir_page()){
            remove_action('wp_enqueue_scripts', 'geodir_templates_scripts');
            remove_action('wp_enqueue_scripts', 'geodir_templates_styles', 8);  
        }
    }
    

    Thanks,
    Kiran

Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket