Not mimified with minify switched ON
-
About monification in BODY.
the first script in BODY is bootstrap “wp-content/themes/enfold-child/vendors/bootstrap/3.3.5/js/bootstrap.min.js”, which is already minified in source file. But strange situation is that when W3TC minifies scripts this bootstrap script becomes UNminified (as you can see from screenshot) Mysterious situation.This page has a good explanation:
Both async and defer scripts begin to download immediately without pausing the parser and both support an optional onload handler to address the common need to perform initialization which depends on the script. The difference between async and defer centers around when the script is executed. Each async script executes at the first opportunity after it is finished downloading and before the window’s load event. This means it’s possible (and likely) that async scripts are not executed in the order in which they occur in the page. The defer scripts, on the other hand, are guaranteed to be executed in the order they occur in the page. That execution starts after parsing is completely finished, but before the document’s DOMContentLoaded event.
https://davidwalsh.name/html5-async
Also, it’s possible bootstrap is minified but the browser shows it as unminified.
1. Thanks for explanation and your time. Now I understand that defer suits me well.
2. About bootstrap. in this case why there are comments and new lines? (i’ve put both options ON to remove it). Because of this I think that minification process not minifies this files in BODY and not thrown any errors. :-\ I believe there is some hidden sh*tMost of all, in BODY section there is avia.js (not avia-compat.js as above) which also has “use strict”. But chrome don’t throw any error as before.
A lot of minified files have a “sourcemap”.
So when you open developer tools, Chrome obtains the unminified version using the location of the sourcemap.
This helps because minified files typically have just one line or maybe 2-3 and debugging is difficult as you don’t have the advantage of a line number.
Possibly that’s the case here.
But in this case why GTmetrix tells me that files are not minified?
Most of all, as you saw JS file in head is minified, but GTmetrix tells it’s not :-\ i’m confusedYeah the problem is still there.
What I am saying is that the bootstrap part is minified but appears unminified in Chrome developer tools.
The other part is unminified.
You can directly load the file in the browser (no development tools) to see it.
Finally, i’ve decided to minify JS files myself. Will tell theme author to minify it in future versions.
For now I have last strange thing.
Here is minified by W3TC file. But GTMetrix tells me that it’s not minified. Am I right, that issue is with minification mechanism used by W3TC? Can it be improved?The same thing is about JS minified files and minified HTML.
Hmm. That’s strange. That file seems minified. Don’t understand why GTMetrix is complaining. But the difference is just 120B which is not much.
Minification can always be improved. Consider CSS. If you have code like:
body { background: #808080; } ... body { background: #808080; }
Not all minifiers will recognize that the code is being repeated. Only some such as Clean-CSS will do that.
In your case for the other file, possible W3TC has some bug.
Yeah, I understand that 120B it’s OK and not a problem. But just a curious where they found this bytes.
Togather with this GTmetrix provides their version of minified file. I want to take that and mine and find some tool to compare files and find difference.Also question, is there is W3TC files some place where minification process can be configured?
And Q2: Here is minified JS (GT metrix also tells that it should be minified) and minification is OK but there are comment sections which were not removed by W3TC (I have comment removal ON)
Minifiers usually have options about removing comments.
In the default seeting, they’ll remove general comments but not the one containing license information. It’s of course possible to change options so that all comments are removed. I don’t know where in the W3TC plugin folder the option is set.
Somewhere here probably: https://plugins.trac.www.ads-software.com/browser/w3-total-cache/#trunk/lib/Minify/Minify
About your JS file in the head, PageSpeed doesn’t complain if you see it directly at their site.
Point 1: Ok. About minification mechanism I’ll try to find out how to configure it.
Point 2: About JS. Here is what GT tells me. As for example let’s take a look at JS in BODY.
Version1 – this is minified by W3TC file.
Version2 – this is file minified by GT. as they tell from screenshot above there are 934 bytes available for compression. I’ve tried to compare this files with WinMarge utility and got interesting thing. On these document opening i’ve got notification about difference in carriage return breaks (screenshot). And when opened I got such picture.CONCLUSION: From this I can see that W3TC minification doesn’t remove line breaks (even with this option ON). For me it’s quite difficult to find the reason of this behavior (as also with comments removal described in previous posts). Anyway I’ll try.
Together this my ask is: could you be so kind and also make some investigation and fixes if needed.
Thanks for your support, and effective, fast communication. I believe that together with users we can make this plugin better and better.About mechanism used for minification. In sources i’ve found library used for minification by default. it’s JSMin-PHP. I’ve followed by link from copyrights and found that this project stopped. Here are author words:
This project is unmaintained. I stopped using it years ago. You shouldn’t use it. You shouldn’t use any version of JSMin. There are much better tools available now.
Here are some of them:- Uglify
- Google Closure Compiler
- JShrink
So based on this, don’t you think that it’s a good time to change default minification lib to some from purposed?
Great findings.
About carriage return breaks, I believe its for browser compatibility for old browsers.
You should report your findings with the plugin author.
- The topic ‘Not mimified with minify switched ON’ is closed to new replies.