0

I want to load some javascript for the front page of my theme after jquery and jquery ui is loaded. what would be the hook to use?

I am aware of the functions.php and I have used is_front_page(). By inserting wp_register_script in functions.php, I can queue the script after the libraries I want loaded but I also want to load it only on the frontpage. Using is_front_page() on header.php, the script gets loaded ahead of jquery.

How could I load my javascript after loading the jquery and only on the front page?

1

Enqueue the script in your functions.php instead of the header, wrap it in the conditional tags ( in your case is_front_page ) and use the proper enqueue dependency, you can change the load order by altering the add_action $priority parameter or use $in_footer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.