1/**
2 * Enqueue your theme styles and scripts in functions.php
3 * use time() instead of a proper versioning to avoid caching when developing
4 */
5function my_theme_enqueue_scripts() {
6 wp_enqueue_style( 'default-style', get_stylesheet_uri(), [], '1.0.0', 'all' ); //default styles.css
7 wp_enqueue_style( 'main-style', get_stylesheet_directory_uri() . '/assets/css/main.min.css', [], time(), 'all' );
8 wp_enqueue_script( 'main-script', get_stylesheet_directory_uri() . '/assets/js/main.min.js', [], time(), false );
9}
10add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_scripts' );
11
1function wpdocs_theme_name_scripts() {
2 wp_enqueue_style( 'style-name', get_stylesheet_uri() ); /* enqueues style.css */
3 /* if you want to enqueue other styles use: */
4 /* wp_enqueue_style( 'style-name', get_template_directory_uri() . '/css/your-style-name.css' ); */
5 wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
6}
7add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
1function script_that_requires_jquery() {
2 wp_register_script( 'script-with-dependency', 'http://www.example.com/script-with-dependency.js', array( 'jquery' ), '1.0.0', true );
3 wp_enqueue_script( 'script-with-dependency' );
4}
5add_action( 'wp_enqueue_scripts', 'script_that_requires_jquery' );