I’m loading a JavaScript file using wp_enqueue_script
into my theme. However, along with it, I’m loading several jQuery files as well, as dependencies for the enqueued script (which has already been concatenated and minified by Grunt). Here is my code:
add_action('wp_enqueue_scripts', function() {
wp_enqueue_script( 'customscripts', get_template_directory_uri() . '/assets/js/main.min.js', array('jquery', 'jquery-form', 'json2', 'jquery-ui-autocomplete'), NULL, true );
});
For the dependencies array, how would I go about concatenating and minifying those jQuery dependencies? I’m trying to get my site to load as fast as possible, and the less JS files it has to load the better. Also if it were possible to make them load asynchronously (using the async
property for <script>
tags) that’d be ace.
I’d rather do it without using a plugin but I will use a plugin if necessary.
Thanks for any help 🙂