Adding or Enqueue Jquery and CSS Right way in WordPress

Introduction WordPress comes by default with the latest version of JQuery and it’s relatively easy to add the reference to the scripts and css using a wordpress hook. Just add the code bleow to your functions.php file. Solution

how to enque scripts and css

Table of Content

Introduction

WordPress comes by default with the latest version of JQuery and it’s relatively easy to add the reference to the scripts and css using a wordpress hook. Just add the code bleow to your functions.php file.

Solution

[code language="javascript"]
/**
* Add the JQuery, Scripts and CSS Proper Way
*/
function wp_guru_enque() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() ); // Enqueue style
wp_enqueue_script( 'jquery' ); //Enqueue jquery
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/scripts/script.js', array(), '1.0.0', true ); // Enqueue script
}

add_action( 'wp_enqueue_scripts', 'wp_guru_enque' );
[/code]

About Author

Robin Thebe

Digital Strategist based in Sydney.

I am multi disciplined web developer based in Sydney focusing around WordPress web design, wordpress development, SEO Services, SEM and Email Marketing.