Conditional wp_enqueue_script on a page

init is much earlier than page template loading and not appropriate place for enqueues (despite many tutorials and docs using it for that).

Hook your function to wp_enqueue_scripts and make sure you are doing that hooking before wp_head() call in template.

Leave a Comment