WordPress: Enqueuing Javascript File Dependencies Correctly
Mod of the MailChimp WP widget to include Placeholders jQuery Plugin. Notice the first function is wp_register_script. This doesn’t load it unless something later depends on it. Also if another plugin has it’s own version and uses the same handle name then this will prevent duplicate loads even if the script sources are different.
|
1 2 3 4 5 6 7 8 |
// Placeholder plugin dependency if requried $depends = array('jquery', 'jquery-form'); if (get_option('mc_use_placeholders') == 'on' || true){ $depends[] = ('jquery-placeholder'); wp_register_script('jquery-placeholder', MCSF_URL.'js/jquery.placeholder.min.js', array('jquery')); } wp_enqueue_script('mailchimpSF_main_js', MCSF_URL.'js/mailchimp.js', $depends, MCSF_VER); |


