Registering/Enqueuing Scripts/Styles
sakinshrestha opened this issue · comments
- When registering and enqueueing scripts in
functions.php
, you don't need to callwp_register_script()
andwp_enqueue_script()
. Just callwp_enqueue_script()
:
wp_register_script( 'modernizr', trailingslashit( get_template_directory_uri() ) . 'js/modernizr-min.js', array(), '3.3.1', false );
wp_enqueue_script( 'modernizr' );
Should simply be:
wp_enqueue_script( 'modernizr', trailingslashit( get_template_directory_uri() ) . 'js/modernizr-min.js', array(), '3.3.1', false );
- Only register if you don't know if you're going to load it immediately
- Same goes for
wp_register_style()
andwp_enqueue_style()