For a function that enqueues scripts, the action hook you use should actually be “wp_enqueue_scripts” for the front of the site, and “admin_enqueue_scripts” for the admin side of things. This is the proper time to enqueue scripts.
While you can technically do it anytime before wp_head, this is the best place because it’s pretty much the last possible chance to do it, thus ensuring that everything else that can be done before script output has been done, making your logic all work properly.
Related Posts:
- Opinions and recommendations on the best barebones base theme [closed]
- Customizing a WordPress theme without changing it?
- How to Link External jQuery/Javascript files with WordPress
- How do I append multiple taxonomies to the URL?
- How to completely disable a taxonomy archive on the frontend?
- Any official way to create an admin theme?
- Splitting an Evolving Site into Multiple Sites, or Maintaining as One Site?
- wp_insert_term – parent & child problem
- How can I select a primary category?
- Building useful features into your theme
- Multisite: setting theme and options when a new blog is created
- Editing theme files and access to the Code pages only to super-admin?
- Change Default Image HTML
- How to delete default themes
- Extra User Profile Field Upload File / Image
- Edit raw HTML of the landing page
- Problem : deletion failed, the theme requested does not exist
- Theme Activation, Create Database Tables
- Will activating a different theme preserve custom settings to current theme?
- Can I apply a WP theme to a specific custom page template?
- How to trigger function on theme delete?
- Setting a static home page and blog page without using the settings
- Two Navigation Menus – secondary nav is including main nav
- Removing the “Popular Terms” area from the Taxonomy Edit Screen in the Admin Area
- Possible to put header-{your_custom_template}.php in subdirectory?
- Renaming the Twenty Fourteen WordPress theme
- Protect changes made to the theme when updating
- Theme Development Admin Area [closed]
- How to set a single theme directory on a multisite blog?
- Hide custom field if empty
- Static page not working
- Custom options below pages/posts editor?
- How to add textarea field to taxonomy (tag)?
- Problem of running development copy of WordPress on WebMatrix?
- Migrating a taxonomy’s tags to the native category
- Different logo on homepage
- the_content() is not displaying content, why? [closed]
- What is the correct way to integrate wordpress with another php application?
- Customizing page content layout
- Tips for managing code when developing a parent theme framework
- Trying to uninstall a theme, but it’s hijacking my home page
- Most wp_nav_menu parameters ignored
- Using the same database on another Subdomain
- Get wordpress taxonomy slug name(s) to use as div class
- How To Show Different Footers For Different Post Types Pages?
- Dropdown taxonomy lists in admin menu
- Taxonomy Overview Page?
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- How to include stylesheet in custom admin using parent_slug
- Custom fields not displaying on front end
- My blog suddenly can’t find my stylesheet?
- Use wp_list_categories to list parent categories from actual term
- Customizing 1 theme for multiple blogs in a multisite setup
- Is there any way to modify images from a theme using the web interface?
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Taxonomy template is not reading
- Set a Default CPT taxonomy by taxonomy id
- Default and warning messages & no login
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- dynamic image path within a javascript file
- WordPress add taxonomies/terms list as a menu in archive page
- Display ads by location [closed]
- WordPress Dashboard Problem [closed]
- Theme Dev | Convert Template to Theme
- How to add a post with new Taxonomy without assigning to default category?
- Sort by Custom Post Type (Multiple Loop)
- Work on theme files on a server & browser preview before installing it
- create taxonomy
- Create a child Theme or custom Theme
- Theme Options Menu Item – Permission Issue
- Sub-Theme (based on Taxonomies)
- Static front page displaying twice
- Custom Search only for my Custom Taxonomy Page – data
- Static posts page is not working
- Custom Taxonomy Template Post List with Sort Order
- Is it possible to stop a theme activation when a certain plugin is not activated
- add image size still doesn’t work even after regenerating thumbnails
- Best location for theme translation files
- Single Page WordPress CSS and JS links
- Display taxonomy term only if there’s a value
- How to develop a theme while having another show up
- How to Register and Display Widget for Custom taxonomy
- Switch to other theme at URL
- How to change sidebar per page?
- Fetch taxonomies by custom post type id array
- Page dissapears when i click save
- How can I get the custom post type assigned to a current custom taxonomy for query?
- Is wordpress big enough for my project [closed]
- Displaying Custom Taxonomy without a hyperlink
- Adding a template in WPTouch
- WP Nanoplex 1.0.3 malfunction
- Custom field with terms from another taxonomy programmatically
- Understanding the child / parent theme relationship
- How to order taxonomy terms by most recent post?
- WordPress theme works on linux servers but white screen after move to Xampp
- Why, when it comes to custom background and image, does ‘The first value registered’ win?
- How to add different link on each Post [closed]
- Loop custom post type by taxonomy (Category)
- Turning WordPress Into full-featured website?
- Localization issue. Codestyling localization, incompatible theme