[theme-reviewers] wp_enqueue_style

Otto otto at ottodestruct.com
Fri Jun 3 10:54:28 UTC 2011


On Fri, Jun 3, 2011 at 5:48 AM, Vicky Arulsingam
<vicky.arulsingam at gmail.com> wrote:
>> I see a few issues:
>> 1) Styles should be enqueued and *hooked* in; front-end styles should be
>> hooked into 'wp_print_styles'.
>
> I've seen a number of themes that use wp_enqueue_style() / wp_enqueue_script
> within the header.php.  I'll be sure to distinguish between wp_print_style
> and wp_enqueue_style in future reviews.

No, enqueueing of styles for the front end of the site should be in a
function hooked to the wp_enqueue_scripts action, *not* to
wp_print_styles.

Correct way:

add_action('wp_enqueue_scripts','my_enqueue_stuff');
function my_enqueue_stuff() {
  wp_enqueue_styles(...);
}

The reason for this is that wp_print_styles is the last possible
moment to enqueue a style, and so it should be reserved for
*dequeueing* styles instead. Enqueue early, dequeue late.

-Otto


More information about the theme-reviewers mailing list