• Hi there,

    I am minifiying jQuery script too, and all it’s working fine.

    I need to add this snippet:

    if(!wp_script_is('jquery', 'done')) {
                wp_enqueue_script('jquery');
            }

    wp_add_inline_script( 'jquery-migrate', "jQuery(document).ready(function(){alert('debug')});" );

    Is there a way to add this few lines AFTER the aggregated autoptimize js file?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frank Goossens

    (@futtta)

    no, as Autoptimize injects the JS later (after the HTML has been rendered but before it’s send to the browser) and it is injected before the closing body-tag. you can change the “injection-point” by using the AO API, e.g.

    
    add_filter('autoptimize_filter_js_replacetag','my_ao_override_js_replacetag',10,1);
    function my_ao_override_js_replacetag($replacetag) {
            return array("<injectjs />","replace");
            }

    so if you add a fake “injectjs”-tag (in your theme, before the wp_footer()) and you make sure the result of the above PHP-snippet is added in the footer and excluded from autoptimize, then it could work.

    hope this helps,
    frank

    Thread Starter Davide Prevosto

    (@daweb)

    Thank you @futtta, I am really sorry but it’s not so clear for me. May I ask your further help, please?

    Plugin Author Frank Goossens

    (@futtta)

    pretty much in the dark here as well @daweb, as your snippet is PHP and I don’t know where it ends up in the HTML. hence the somewhat generic reply. I’ll need more info if you need more help ??

    frank

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Inline Ajax Call’ is closed to new replies.