• Resolved rexviber

    (@rexviber)


    Hello,

    Is there any way to disable ONLY „Also aggregate inline JS?” option on a specific page?

    PS: Exclude scripts is not an option because it also disables „Aggregate JS-files” option.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    you can disable “aggregate inline JS” with a filter;

    add_filter('autoptimize_js_include_inline', '__return_false' );

    so based on that you can do something like;

    add_filter('autoptimize_js_include_inline', function( $state ) {
      if ( true === $example_condition ) {
        return false;
      }
    
    return true;  
    } );

    so if you change the $example_condition to something relevant for identifying a page (based on URL or page ID) , you could use that?

    Thread Starter rexviber

    (@rexviber)

    Hello,

    It works! Except that the first return must be true and the second false.

    Thank you!

    LATER EDIT BELOW

    This code totally works:

    add_filter('autoptimize_js_include_inline', function( $state ) {
      if ( is_page( 'YOUR_PAGE_SLUG_HERE' ) ) {
        return false;
      }
    return true;
    });
    • This reply was modified 3 years, 4 months ago by rexviber.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome, feel free to leave a review of the plugin and support here! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Aggregate inline JS on specific page’ is closed to new replies.