Skip to content

Instantly share code, notes, and snippets.

@danielpataki
Last active February 19, 2018 20:45
Show Gist options
  • Save danielpataki/367fa92182f3fbaa10c8 to your computer and use it in GitHub Desktop.
Save danielpataki/367fa92182f3fbaa10c8 to your computer and use it in GitHub Desktop.
WordPress Enqueues
function my_assets() {
wp_register_script( 'owl-carousel', get_stylesheet_directory_uri() . '/owl.carousel.js', array( 'jquery' ) );
wp_enqueue_script( 'owl-carousel' );
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
function my_assets() {
wp_enqueue_style( 'theme-style', get_stylesheet_uri(), array( 'reset' ) );
wp_enqueue_style( 'reset', get_stylesheet_directory_uri() . '/reset.css' ) );
wp_enqueue_script( 'owl-carousel', get_stylesheet_directory_uri() . '/owl.carousel.js', array( 'jquery' ) );
wp_enqueue_script( 'theme-scripts', get_stylesheet_directory_uri() . '/website-scripts.js', array( 'owl-carousel', 'jquery' ), '1.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
wp_enqueue_script( $handle, $source, $dependencies, $version, $in_footer );
wp_enqueue_style( $handle, $source, $dependencies, $version, $media );
function my_assets() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', get_template_directory_uri() . '/jquery-latest.js' );
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
<!DOCTYPE html>
<head>
<script type='text/javascript' src='jquery.js'>
<script type='text/javascript' src='owl.carousel.js'></script>
<link rel='stylesheet' type='text/css' href='reset.css'>
<link rel='stylesheet' type='text/css' href='styles.css'>
</head>
<body>
Website content here
<script type='text/javascript' src='website-scripts.js'></script>
</body>
</html>
@trevorberman
Copy link

Hi Daniel,

It doesn't seem like Github has a way to make pull requests on Gists, so I wanted to ask if you'd consider merging the edit from my fork.

Found this while working through what the 🔥 enqueing does in WP, via your great article for WPMU DEV. Thanks for the super explanations and clearly illustrative code!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment