Gravatar Hovercards uses wp_enqueue_script incorrectly.
|Reported by:||ericmann||Owned by:||mdawaffe|
The code in the Gravatar Hovercards module uses wp_enqueue_scripts() to queue up its script files and various dependencies. It then uses wp_localize_scripts() to add some PHP variables for use in JS.
But then the system calls wp_print_scripts() directly (hooked onto the wp_footer action) to output its script files to the page. While this works, it's not the right action or the right approach for printing footer scripts. Other plugins/modules cannot hook in to change the execution order or unhook the scripts if needed. Also, the dependency of the module on jQuery can cause the library to be loaded twice in some situations (i.e. when jQuery is automatically concatenated with other scripts by a separate plugin).
Instead of hooking to wp_footer, the code should be using the in_footer parameter of wp_enqueue_scripts() and hooking to the wp_enqueue_scripts action. This is the recommended way of deferring JS files to the footer.