• Resolved alekv

    (@alekv)


    Hi

    Is there a way to exclude inline JavaScript from being combined and minified?

    Thanks
    Aleks

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

    (@stoyangeorgiev)

    Hello there @alekv,

    You can exclude inline script from being combined using the filter we’ve designed for that purpose. Here’s an example of the code:

    add_filter( 'sgo_javascript_combine_excluded_inline_content', 'js_combine_exclude_inline_script' );
    function js_combine_exclude_inline_script( $exclude_list ) {
        $exclude_list[] = 'first few symbols of inline content script';
    
        return $exclude_list;
    }

    If you wish to exclude a specific script from minification, 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

Viewing 1 replies (of 1 total)
  • The topic ‘How to exclude inline JavaScript?’ is closed to new replies.