Scripts and stylesheets should always be loaded in the head or in the footer via the wp_enqueue_scripts action hook. wp_enqueue_scripts is the proper hook to use when enqueuing items that are meant to appear on the front end
The init hook executes before wp_head which is to early for script to load in the header. The wp_enqueue_scripts action hook is executed right after wp_head, allowing scripts and styles to be loaded properly. This also have the benefit of naming script dependencies and ordering scripts and styles to load properly
Related Posts:
- What is the earliest Hook a Script can use?
- True parameter but jquery register in header and not in the footer with wp_register_script
- Extract image from content and set it as the featured image
- Add action hook conditionally – only when home.php in use
- How can I tell if I’m on a login page? [duplicate]
- How to hook into the quick edit action?
- WooCommerce add_action hook results in 500 error
- Enqueuing Script in functions.php vs on the page
- Passing arguments to my function with do_action and add_action is not working
- Accepted arguments value in hook functions
- Which action hook to use for function?
- Modify a function without editing template
- Don’t delete a page if it holds users
- Not sure if enqueuing js scripts properly
- Which action does wp_update_user triggers?
- How can I get my Script to work on the Login page?
- Trigger a custom function when option are saved in admin area
- how to en-queue jQuery to load before the tag
- Attempt to change jQuery version caused White Screen of Death
- Override the WordPress core function wp_referer_field
- Scripts not loading when using the wp_enqueue_scripts action
- Is there a way to prevent a function/method from being called outside a specific hook?
- In jquery use php variable to execute an enqueued jquery file
- Run a jquery script on on a certain template page
- Adding code before post title with the_title produces weird results
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- Add back in child theme what the parent theme removed with remove_action
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- How to load jQuery in TOP of wp_footer?
- Changing where my author box is printed
- Insert Content Before div#main from the functions.php File
- Include Jquery libraries in wordpress theme?
- Replace admin header logo with an image
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- colorbox not loading in
- How to use wp_enqueue_script properly?
- Does hook have an effect on increasing the page load?
- Save_post – Warning: Cannot modify header information
- post value to function with Ajax and jQuery
- How Do I Unhook This Parent Theme Function?
- WordPress hooks to call a function inside a construct
- WordPress Jquery+scripts enqueue issue
- delete_term is not working properly with add_action()
- Function attached to cron job not running but will run if called manually
- Refresh page after form action
- How to create thumbnails for PDF uploads?
- How to enqueue every script in a folder automatically?
- How to save Uploaded image in custom option panel?
- wp_register_script not loading as expected
- Use latest jQuery in WordPress (admin interface)
- Issue adding text after short description on product pages Woocommerce [closed]
- Customize “the_posts_pagination” and put list instead div
- woocommerce target button with class after ajax update
- WordPress doesn’t Load JQuery Now? Do I need to enqueue JQuery also?
- How to select a page within admin?
- How to manage arrays from custom functions stored in functions.php?
- Gravity Forms – Using a Form to Pre-populate A Gravity Form [closed]
- wp_is_mobile dequeue not working
- Running a script before absolutely everything
- How to display post content instead of excerpt
- Why won’t my scripts load?
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘greenday_head’ not found or invalid function name
- Loading CDN that requires jQuery in WordPress
- Only let plugin add actions to wp_head & wp_footer on single posts
- How to use wp_trash_post (or wp_delete_post) for deleting a (or all) post(s) from custom post type?
- Load jquery only for certain pages in the backend
- Set Taxonomy based on post status
- echo custom fields with AJAX
- How do I hook into the container of wp_nav_menu?
- Remove links from the_content when using filters wp_trim_excerpt
- Missing argument for the function
- Function not working inside of a function in functions.php
- Init action and refresh page after form action
- get content from page through AJAX
- How to pass hook variable to function?
- How do I find the code executed when wp_head() is called?
- Why is this function crashing my wordpress installation? [closed]
- wp_enqueue_script() not working
- How to Override Page Template if URL matches query?
- How to use WP conditional tag in a functions.php with OCEANWP Theme?
- custom error message for empty username and password using authenticate filter not working
- Modifying a WordPress Plugin
- Get post_author email for Zapier Integration
- Postback redirect through add_action is not triggered
- Hook into all password resets in WordPress and get password before hashing?
- How to change form action of wp-login page with a function
- Execute jQuery with custom event listener after successfully add an item to the cart
- WordPress undefined function error on using add_action() in functions.php
- Pass arguments to function class with do_action()
- What add_action reference should I be using or should I use do_action?
- WordPress HTML Helper
- save_post hook – headers already sent?
- Exclude javascript in certain page url and all following url’s after forward slash
- Add custom fields after post/page title
- Ajax call does not work for this custom code
- Force resize for all video content
- Unhook the comment form in Buddypress
- add query string to all pages after user logged in
- Why my wp_enqueue_script doesnt work on some page?
- How can I able to exclude ‘Category’ and ‘Tag’ slug from the URL in WordPress without reloading to new site?