kasparsd / minit

A WordPress plugin to combine CSS and Javascript files.
GNU General Public License v2.0
286 stars 46 forks source link

minit_exclude_js & re-enqueue back to header #96

Open omniacode opened 7 years ago

omniacode commented 7 years ago

Hello -

I stumbled upon this plugin looking for a real way to compile both css & js files into single files to reduce the amount of requests being made by WP themes, and I have to say I like where this project is going :)

However, I am messing around with the minit_exclude_js filter and I hate to sound like such a n00b, but I wanted to use the filter to exclude jquery core & jquery-migrate because it is seemingly breaking every site I install the plugin on. As I am sure you already know that most themes do not follow great standards, but by using the filter it moves both files to the footer which still causes issues with jquery placed within the page by plugins and what not.

Is there a way to exclude these two files and re-enqueue them back into the header? I know it sounds quite counter productive, but even doing so still eliminates 20+ requests per theme.

Thanks

GermontZ commented 7 years ago

Try this. add_filter( 'minit-exclude-js', 'exclude_my_file' ); add_filter( 'minit-exclude-css', 'exclude_my_file' ); function exclude_my_file( $exclude ) { // ID of the script that was enqueued $exclude[] = 'jquery'; $exclude[] = 'jquery-migrate'; return $exclude; }

Other than that, see also my issue about the same topic: https://github.com/kasparsd/minit/issues/57

omniacode commented 7 years ago

@GermontZ -

Thanks for the reply, however I did try the suggested filter, however by doing so it removes the files that are excluded from the head section and places them right above the minit async call in the footer.

I even tired to use wp_deregister_script & wp_register_script to try and force it back into the head section with no luck.

I'll hold off on this for now until some type of work around pops up. Thanks.

kasparsd commented 5 years ago

Confirmed the bug locally -- the filter does exclude the file but it doesn't print it out in the header.