• Resolved e555

    (@e555)


    Hello. I have a javascript that basically does a document.write to display an image. Combine JavaScript Files prevents the image from showing. How can I exclude this script? It is not showing up on the list of scripts to exclude

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

    (@stoyangeorgiev)

    Hello there @e555,
    If your script is inline you can use this filter to exclude it

    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;
    }

    You can also use this one by adding your script handle:

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

    Depending on the case you can choose the one that suits best for you. Those code snippets can be added to your functions.php file. Keep in mind that it is better to put them in your child-themes functions.php. If you have any issues after that feel free to contact us.

    Kind regards,
    Stoyan

    • This reply was modified 4 years, 4 months ago by Stoyan Georgiev. Reason: Did not ping the participant when first added the comment
Viewing 1 replies (of 1 total)
  • The topic ‘Combine JavaScript Files breaks a small script’ is closed to new replies.