• Resolved wpwebdevj

    (@wpwebdevj)


    I am trying to load my own script after the Autoptimized javascript is called.

    add_action( 'wp_footer', function () { ?>
    <!--noptimize-->
    <script defer src="/my-custom-js.js"></script>
    <!--/noptimize-->
    <?php }, 9999999 );

    No matter how high of a priority I give this function, it always gets loaded before the Autoptimized javascript. Is there any way to make it load after?

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

    (@optimizingmatters)

    can you try using this code snippet;

    add_filter('autoptimize_filter_js_replacetag','aojs_after_noptimize',10,1);
    function aojs_after_noptimize( $replacetag ) {
        return array( '<!--/noptimize-->', 'after' );
    }

    frank

Viewing 1 replies (of 1 total)

The topic ‘Load a custom script after the Autoptimized combined script’ is closed to new replies.