how to registerer script and then enqueue when it needed

 function wpb_adding_scripts() {

 
wp_register_script(‘my_amazing_script’, plugins_url(‘amazing_script.js’, __FILE__), array(‘jquery’),‘1.1’, true);
 
wp_enqueue_script(‘my_amazing_script’);
}
  
add_action( ‘wp_enqueue_scripts’, ‘wpb_adding_scripts’ );
refre= https://developer.wordpress.org/reference/functions/wp_register_script/
function wpb_adding_styles() {
wp_register_style(‘my_stylesheet’, plugins_url(‘my-stylesheet.css’, __FILE__));
wp_enqueue_style(‘my_stylesheet’);
}
add_action( ‘wp_enqueue_scripts’, ‘wpb_adding_styles’ ); 

Leave a Comment

Your email address will not be published. Required fields are marked *