• Resolved info.brandaware

    (@infobrandaware)


    Autoptimize works perfectly with the exception of a problem in IE8. placeholdr.js is required by ie8 for forms and must execute after the autoptimize combined footer js, but it currently appears (bracketed by IE conditionals) before the autoptimize combined footer js.

    Sections of the relevant enqueue statements appear below

    How can I change the order?

    Thanks,

    Brian
    Since I need a lower level of jquery, I dequeue the standard version:

    function pp_jquery_enqueue() {
    wp_deregister_script('jquery');
    wp_register_script('jquery', get_template_directory_uri() . '/assets/js/vendor/jquery-1.9.1.min.js', array(), null, true);
    wp_enqueue_script('jquery');
    }
    if (!is_admin()) add_action("wp_enqueue_scripts", "pp_jquery_enqueue", 0);

    The relevant statements from the enqueue portion of functions.php:

    function pp_scripts() {
    ...
    wp_register_script('placeholdr',  get_template_directory_uri() . '/assets/js/vendor/placeholdr.min.js', array('jquery'), null, true);
    ...
    wp_enqueue_script('placeholdr');
    ...
    global $wp_scripts;
    $wp_scripts->add_data('placeholdr', 'conditional', 'lt IE 9');
    }
    add_action('wp_enqueue_scripts', 'pp_scripts', 1);
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frank Goossens

    (@futtta)

    AO doesn’t the normal enqueuing logic and always completely ignores IE-cc’s.

    but what you could try, is use AO’s API to tell it to inject elsewhere, e.g. assuming you have a footer-tag;

    add_filter('autoptimize_filter_js_replacetag','override_js_replacetag',10,1);
    function override_js_replacetag($replacetag) {
            return array("<footer>","after");
            }

    the 2nd parameter can be “before”, “after” or “replace” (for that last on you would typically add a specific tag in your footer.html)

    hope this helps,
    frank

    Thread Starter info.brandaware

    (@infobrandaware)

    Frank,

    Thanks for the quick reply.

    It worked perfectly with <figure></figure>, with the autoptimize js appearing between the two tags.

    Thanks,

    Brian

    P.S. for others attempting this:

    It didn’t work with the footer tag probably because my footer tag is more than just <footer>:
    <footer id="colophon" class="site-footer" role="contentinfo">

    It didn’t work with a comment tag <!– replace –> throwing an error message about a missing <!–/noptimize–>

    Plugin Author Frank Goossens

    (@futtta)

    ah, you could also have done;

    return array("<footer","before");

    anyway, great you got it working! ??

    enjoy the rest of your sunday
    frank

    Awesome Again!!!

    Your final option worked for me. There are so many ways to customize AO. Frank you are so great. Developing in 360 degree way is so impossible, but your way of thinking is so high. I became fan of AO and also got excited by autoptimize filters here.
    https://github.com/futtta/autoptimize
    All the way your plugin is fantastic. which made life easier.

    Plugin Author Frank Goossens

    (@futtta)

    thanks @thiyagesh ??

    just committed some major improvements to the github-version (which will result in a significant speed-up of the minification), so don’t hesitate to download the zip and test that soon-to-be AO2.2

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘enqueue ie conditional js after autoptimize js (all in footer)’ is closed to new replies.