Closed szepeviktor closed 8 years ago
It is a very nifty case:
script's src contained ....js?rev=1.2.3
revision number, it's version was not set.
// Skip if the file is not hosted locally
skipped the script but later it got into add()
JS call.
Could you check for ?
in the script's name and handle it accordingly?
Now I think that even without ?
in the url minit minifies it's own generated JS.
I think the header's combined JS gets minified again in the footer.
print_scripts_array
fires twice.
As I see if the combined script exists then it does not get async_print
-ed.
Could it be that if ( ! $script_relative_path ) {
should be if ( $script_relative_path ) {
?
@szepeviktor I have also experienced the issue you described, however it is not related to the external scripts. I am not sure what causes it.
I think the !
in if
.
Oh! I see
Print external scripts asynchronously in the footer
So locally hosted scripts are loaded synchronously.
off: I am trying to reach PageSpeed 100 thus loading everything async. This plugin is developed for looking at the HTML source easily: https://wordpress.org/plugins/frontend-debugger/
Could it be that the combined script from the header get re-minit-ed in the footer?
@szepeviktor It shouldn't because Minit keeps track of scripts that have been combined and excludes them from being "Minited" again:
https://github.com/kasparsd/minit/blob/master/minit.php#L169
Thank you! I am still in the understanding phase. Would you mind if I put together a PR with only comments?
@kasparsd I think I've found the reason using Frontend Debugger. In the first go scripts registered in the header are minited, then footer scripts. At the next page load these two minited scripts are minited again into one.
Are you planning to work on it?
In the first go scripts registered in the header are minited, then footer scripts. At the next page load these two minited scripts are minited again into one.
Exactly, @szepeviktor!
Minit captures all instances of print_scripts_array
and creates the Minit version for the files enqueued until that point.
The solution is to do the Minit process right before wp_print_footer_scripts
and use print_scripts_array
only to capture the registered scripts.
@kasparsd Could you implement that?
@szepeviktor Could you test the feature/restructure
branch https://github.com/kasparsd/minit/tree/feature/restructure and let me know if it fixes the issue.
I consider this to be solved.