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
- Taxonomy question how to add more data
- Do not show one specific widget on one specific page
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- stylesheet is not readable error after installation
- Custom Taxonomy Term Archive Page Template that Filters 2 or more Taxonomies
- How to add attributes to taxonomies that may be different from post to post?
- Getting associated taxonomies
- Duplicate Custom Post Type and Taxonomy Slug
- Theme option not saved if in wp_editor() and html decoded
- Switching content between summer and winter
- Troubles with Walker_Nav_Menu and closing
- Depending on third party plugins for theme functionality
- How to use multiple archive templates for a taxonomy?
- Website redesign – New theme – Help needed
- How does WordPress load themes? It doesn’t see mine (symlinked)
- How to get list of taxonomy slugs ordered parents>childs?
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- problem in taxonomy-{taxonomy}.php pagination
- wp_query args adding muitiple tax_querys
- ‘Add New’ button not present [closed]
- How to change the format of posts on the hompage?
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- Add success message to category add screen
- wordpress testimonials
- How to style the post previews/links without it affecting the main posts?
- Hiding taxonomies with no children WP_Query & tax_query