• Resolved ajohnclark

    (@ajohnclark)


    I was wondering if there was a way to insert a JS script or script tag below the minified JS file? I don’t want to load the minified JS in the head and just have a small script I’d like to change depending on PHP variables below the minified JS. I couldn’t seem to find any info on this searching, figured I’d ask here.

    PS: Great plugin by the way been using for years.

    Example:
    <script type=”text/javascript” defer src=”example.com/cache/autoptimize/js/autoptimize_dcf4eaeb2c90a267abcbdae4b0e21360.js”></script>
    <script>CODE HERE</script>

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

    (@optimizingmatters)

    not by default, but certainly do-able;

    1. in your theme’s footer add <!–ao-js-insert-here–><script>CODE HERE</script>
    2. and then use this code snippet to tell AO to insert the JS at that point;

    
    add_filter('autoptimize_filter_js_replacetag','ajohnclark_js_replacetag',10,1);
    function ajohnclark_js_replacetag($replacetag) {
            return array("<!--ao-js-insert-here-->","replace");
            }
    Thread Starter ajohnclark

    (@ajohnclark)

    Thank you so much, sorry for delay! 5/5 star continues to be well deserved, have a great day/weekend!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you welcome, enjoy the nearby weekend ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Insert Javascript Below Minified File’ is closed to new replies.