Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
    
I do use enqueue, but I don't want to load my script on every page. –  viyyer Jan 6 '12 at 18:00
add comment

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
thanks. great answer. –  viyyer Jan 6 '12 at 18:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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