sitepoint / wp_theme_basetheme

Base theme for WordPress components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Registering/Enqueuing Scripts/Styles

sakinshrestha opened this issue · comments

  • When registering and enqueueing scripts in functions.php, you don't need to call wp_register_script() and wp_enqueue_script(). Just call wp_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() and wp_enqueue_style()

Closed by #39