• 1. I noticed that when I use exclude jquery from file merge, another file appears that is not merged @@

    2. It’s strange that this gives an “is not defined” error. Although jquery is still loaded first

    https://prntscr.com/26xqvfp

    • This topic was modified 2 years, 9 months ago by minhduc.dev.
Viewing 15 replies - 1 through 15 (of 30 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    It is possible for a plugin to adapt the exclusions using the AO API, I suspect that is what the theme is doing here ducpl ..

    re. “is not defined”; can you copy/paste the full error message?

    frank

    Thread Starter minhduc.dev

    (@ducpl)

    @optimizingmatters ,Thanks for care!

    1. When I include Jquery (Not excluding jquery) everything is fine. I don’t know if this is due to your Theme or Plugin, I will try again by excluding.

    2. Ok here is the error I got “Uncaught ReferenceError: woodmartThemeModule is not defined” addToCartAllTypes.min.js
    I am using Woodmart theme

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    “Uncaught ReferenceError: woodmartThemeModule is not defined” addToCartAllTypes.min.js

    ah, in that case you’ll also have to exclude the theme JS I’m afraid.

    Thread Starter minhduc.dev

    (@ducpl)

    ok, wait a moment, i will exclude the batching of theme files one by one

    Thread Starter minhduc.dev

    (@ducpl)

    I think it’s the woodmart theme

    But why I excluded the files from the pool but the names of the files are not compressed like “Jquery.js”

    https://prntscr.com/26xs82o

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    If AO finds an excluded JS-file and that file is not minified (based on filename) then AO will minify it. These days generally jQuery in WordPress core is minified though (jquery.min.js), so I guess you’re still runnning an older version?

    Thread Starter minhduc.dev

    (@ducpl)

    https://prntscr.com/26xs82o

    I still don’t quite understand.
    As in the picture above, only Jquery.js is compressed, how can I compress other files.
    I like this about your plugins because they don’t show other people what I’m using.
    Thank

    • This reply was modified 2 years, 9 months ago by minhduc.dev.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    because a js-file that ends in min.js is considered minified, so AO does not have to minify it ??

    Thread Starter minhduc.dev

    (@ducpl)

    ok man,
    Is there a way to minimize those names, Because I like to be renamed -_-“

    • This reply was modified 2 years, 9 months ago by minhduc.dev.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    well, the beta version has a filter that can be used to tell AO to (re-)minify all files, so if you’re not afraid to go beta you could download the zip from Github and install that instead of 2.9.5.1 and hook in the filter to return false? ??

    Thread Starter minhduc.dev

    (@ducpl)

    @optimizingmatters

    Wow great brother.
    I want to add a javascript code after the last merged file before the </body> tag, is there any hook to achieve it. ??
    Thanks, have a nice day.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you could use the autoptimize_html_after_minify filter maybe, it holds the full optimized HTML and you can make any change you want including adding stuff right before </body>.

    Thread Starter minhduc.dev

    (@ducpl)

    Awesome! Thanks for the quick reply!

    function ao_js( $content ) {
    
    $content .= str_replace( "</body>", "script type="text/javascript">ok</script></body>",$content );
    
    return $content;
    }
    add_filter( 'autoptimize_html_after_minify', 'ao_js', 1 );

    bro can you write easier code to add js below @@

    <!-- Google Tag Manager -->
    <script data-no-optimize="1" defer>
        (function (w, d, s, l, i) {
                w[l] = w[l] || []; w[l].push({
                    'gtm.start':
                        new Date().getTime(), event: 'gtm.js'
                }); var f = d.getElementsByTagName(s)[0],
                    j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
                        'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
        })(window, document, 'script', 'dataLayer', 'GTM-P4RRabc');
    </script>
    <!-- End Google Tag Manager -->
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    store that JS into a file (in wp-content/uploads) and do an file_get_contents to put the text in a variable and use that variable in the str_replace? ??

    Thread Starter minhduc.dev

    (@ducpl)

    @optimizingmatters Thanks, is there any way to use inline javascript the below code in simple? older brother

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘Plugin not properly handling file merge’ is closed to new replies.