• Could someone please explain to me how wp_enqueue_scripts work and the proper way to include multiple external JavaScripts in my theme (or point me to a good tutorial)?

    I haven’t been able to make sense of the WordPress codex documentation. I have something I’ve been using that seems to be working, but it seems rather redundant and not the most efficient way to do things. Here’s what I’ve got:

    <?php
    		function load_scripts() {
    		   wp_register_script('jshowoff', get_template_directory_uri() . '/js/jquery.jshowoff.min.js', 'jquery' );
    		   wp_register_script('bp-scripts', get_template_directory_uri() . '/js/bp-scripts.js', 'jquery' );
    		   wp_register_script('custom-forms', get_template_directory_uri() . '/js/custom-form-elements.js', 'jquery' );
    		   wp_enqueue_script('jquery');
    		   wp_enqueue_script('jshowoff');
    		   wp_enqueue_script('bp-scripts');
    		   wp_enqueue_script('custom-forms');
    		}
    		add_action('wp_enqueue_scripts', 'load_scripts');
    	?>

    How can I improve this code so I can include multiple external JavaScript files and have them fire when jQuery is loaded?

    Any suggestions? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to use enqueue_script (correctly) with multiple dependents’ is closed to new replies.