I just started using gulp.js which is a task runner like Grunt and a lot of the sites I work on are using WordPress so I was wondering if anyone has some ideas about how to use the combined scripts that gulp will output with WordPress (or for that matter any file that combines multiple files into one).
So say I have gulp setup to concatenate and minify a couple vendor plugin files, like fancybox, and flexslider to a file called plugins.min.js
. I would then load that into my theme by using wp_enqueue_script
from the functions.php
file.
function enqueue_scripts() {
wp_register_script( 'custom-plugins', get_template_directory_uri() . '/assets/js/build/plugins.min.js', array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'custom-plugins' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts' );
But say a plugin gets installed that uses fancybox as well (damn clients). Since the script is being loaded as custom-plugins
instead of fancybox
the fancybox.js
file will be loaded from that plugin as well as my minified script file, which could cause issues and unnecessary file size.
Same goes for wp_enqueue_style
. Any thoughts / ideas on this?