• Resolved hadeermj

    (@hadeermj)


    Hello, I am trying to exclude a JS file but I can’t find it in the drop-down menu the file is wp-content/plugins/arg-multistep-checkout/js how to do I exclude this file?

    thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hey there @hadeermj,

    If you cannot find the specific script in the dropdown menu, you can exclude scripts from being combined using the filter we’ve designed for that purpose. Here’s an example of the code:

    add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' );
    function js_combine_exclude( $exclude_list ) {
        $exclude_list[] = 'script-handle';
        $exclude_list[] = 'script-handle-2';
    
        return $exclude_list;
    }

    If you wish to exclude it from being minified you can use this one :

    add_filter( 'sgo_js_minify_exclude', 'js_minify_exclude' );
    function js_minify_exclude( $exclude_list ) {
        $exclude_list[] = 'script-handle';
        $exclude_list[] = 'script-handle-2';
    
        return $exclude_list;
    }

    Kind regards,
    Stoyan

    Thread Starter hadeermj

    (@hadeermj)

    Thank you very much for your reply could you please assist me with the format is this the correct format?

    add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' );
    function js_combine_exclude( $exclude_list ) {
        $exclude_list[] = 'wp-content/plugins/arg-multistep-checkout/js';
        $exclude_list[] = 'script-handle-2';
    
        return $exclude_list;
    }

    do I just add the path of the file?

    Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hey there @hadeermj,

    At the script-handle part, you would need to add the script handed used when the script is enqueued.

    If you have only one script you wish to exclude you can safely remove the script-handle-2 part of the snippet I’ve sent you.

    If you have multiple scripts you can add them all in the same function.

    Kind regards,
    Stoyan

    Thread Starter hadeermj

    (@hadeermj)

    Thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to exclude JS file’ is closed to new replies.