Answer the question
In order to leave comments, you need to log in
How to minify files in Wordpress using Gulpfile.js?
After installing the theme and plugins in Wordpress, there are a lot of requests to different css and js files.
I would like to optimize this whole thing and put it in one js file, as well as in another css file that will be minified.
For example, I throw off the list from css files
wp-includes/css/dashicons.min.css?ver=5.2.2
wp-includes/css/admin-bar.min.css?ver=5.2.2
wp-includes/css/dist/block-library/style.min.css?ver=5.2.2
wp-content/plugins/woocommerce/assets/css/blocks/style.css?ver=3.6.5
wp-content/plugins/yith-woocommerce-wishlist/assets/css/jquery.selectBox.css?ver=1.2.0
wp-content/plugins/yith-woocommerce-wishlist/assets/css/font-awesome.min.css?ver=4.7.0
wp-content/plugins/yith-woocommerce-wishlist/assets/css/style.css?ver=2.2.11
wp-content/plugins/contact-form-7/includes/css/styles.css?ver=5.1.4
wp-content/plugins/woocommerce/assets/css/woocommerce-layout.css?ver=3.6.5
wp-content/plugins/woocommerce/assets/css/woocommerce-smallscreen.css?ver=3.6.5
wp-content/plugins/woocommerce/assets/css/woocommerce.css?ver=3.6.5
wp-content/plugins/woocommerce/assets/css/prettyPhoto.css?ver=5.2.2
wp-content/themes/mytheme/style.css?ver=5.2.2
wp-content/themes/mytheme/assets/font-awesome/css/font-awesome.min.css?ver=5.2.2
wp-content/themes/mytheme/css/responsive.css?ver=5.2.2
var minifyCSS = require('gulp-minify-css');
gulp.task('css', function(){
gulp.src('src/css/**/*.css')
.pipe(minifyCSS())
.pipe(gulp.dest('themes/mytheme/css'))
});
Answer the question
In order to leave comments, you need to log in
What will you do when plugin styles are updated along with plugins?
In my opinion, you only need to compress your theme's CSS and JS, and don't try to merge everything into one, it still won't work.
If you have a site on HTTPS, then transfer it to the HTTP / 2 protocol, here you can leave a lot of small style files and scripts.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question