futtta / autoptimize

Official Autoptimize repo on Github
https://autoptimize.com/pro/
GNU General Public License v2.0
282 stars 87 forks source link

Exclude js filters does not exclude files in 2.4.0 #181

Closed Ridder90 closed 6 years ago

Ridder90 commented 6 years ago

Hi there. I have the v 2.3.4 (stable) and v 2.4.0-beta-4 installed.

I am running the 2.4.0 because of the following warning:

 PHP Deprecated:  Function create_function() is deprecated in /var/www/html/wp-content/plugins/autoptimize/classes/autoptimizeBase.php on line 213

At the exclude scripts option i have the following string: seal.js, js/jquery/jquery.js,tinymce,mytheme/dist This is excluding all the js files in the dist folder of mytheme. This works in 2.3.4 but not in 2.4.0.

Unfortunately all the files in dist folder get concatenated to.

I am running WP 4.9.8 on PHP 7.2. Let me know if i can help.

futtta commented 6 years ago

wow, that's an ugly regression and -to my surprise- I can reproduce; I'll look into this and update here later tonight/ tomorrow.

groeten uit België! frank

@zytzagoo we indeed seem to have a regression here, no idea where that sneaked in (yet).

futtta commented 6 years ago

Digged in and my being able to reproduce was wrong; the JS file in twentytwelve/js was not minified (as per the filename), so AO minified it while keeping it separate (it is loaded as /wp-content/cache/autoptimize/js/autoptimize_single_xzy.js, the single identifying it as a non-aggregated file that was minified by AO).

So could this be what is happening in your case @Ridder90 ?

futtta commented 6 years ago

any news on this @Ridder90 ?

Ridder90 commented 6 years ago

Hi Futta, sorry for the late response. I checked and you are right! The extra files where indeed the ones i wanted to excluded. I do however also want to exclude them from being minified by autoptimize because i already concat and minify my theme files with gulp. Doing it on run time with autoptimize seems to be a waste of resources. Please correct me if i am wrong.

futtta commented 6 years ago

Doing it on run time with autoptimize seems to be a waste of resources. Please correct me if i am wrong.

correct, but AO does not re-minify if the file is minified according to the filename; xyz.min.js or 123-min.js will not get re-minified, 123.js and abc.js will. so tweaking your gulp setup to make sure the file is recognized as being minified should do the trick :-)

Ridder90 commented 6 years ago

Great! Thanks for the tip. I still would like to have function for my development environment to leave the excluded scripts as they are. Because my development environment uses scripts unminified and with source maps. however I would still like to have autoptimize to concat en minifiy the Wordpress assets on dev.

Maybe xyz.dev.js and 123-dev.js can also be excluded...any thoughts?

futtta commented 6 years ago

you could use fhe autoptimize_filter_js_consider_minified filter (expects an array) to declare dev.js as indicating a minified file, after which AO will leave it as is :)

On Tue, Aug 21, 2018 at 3:16 PM, Ridder90 notifications@github.com wrote:

Great! Thanks for the tip. I still would like to have function for my development environment to leave the excluded scripts as they are. Because my development environment uses scripts unminified and with source maps. however I would still like to have autoptimize to concat en minifiy the Wordpress assets on dev.

Maybe xyz.dev.js and 123-dev.js can also be excluded...any thoughts?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/futtta/autoptimize/issues/181#issuecomment-414669758, or mute the thread https://github.com/notifications/unsubscribe-auth/AALEMa3fwpNr2zX1aA45cYvjQlvjko64ks5uTAgTgaJpZM4V8JMT .

Ridder90 commented 6 years ago

Perfect!