How to Add JavaScript to your theme

From the last WordPress meetup, we discussed How to add javascript to your theme

Inside functions.php, hook into the wp-enqueue_scripts hook

add_action( 'wp_enqueue_scripts', 'wpmia_load-javascript_files');

function wpmia_load_javascript_files() {

wp_register_script( 'info-caroufredsel', get_template_directory_uri() . ' jquery.carouFredSel-5.5.0-packed.js', array ('jquery', '5.5.0', true);

...

...

wp_enqueue_script( 'info-carousel-instance' );

 

if ( is_front_page() ) {

wp_enqueue_script('home-page-main-flex-silder');

} 

}

Author: Amit Ramani

Ever heard of 'tech and tack' together in the same sentence? Chances are you did not. I am part owner of a 'tack' store in Wellington (TACKNRIDER), and full owner of a 'tech' firm(ANTERIK).

Leave a Reply

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