[theme-reviewers] html5.js enqueuing

Paul Appleyard paul at spacecat.com
Thu Jun 13 06:12:51 UTC 2013


Nice. Thanks, Otto.

I'm adding it to my Evernote notebook of WordPress trivia - getting sick 
of trawling through the list archives for edge case clarifications that 
I vaguely remember happening in the list at some time :)

Paul Appleyard

On 13/06/2013 4:00 PM, Otto wrote:
> On Thu, Jun 13, 2013 at 12:44 AM, Paul Appleyard <paul at spacecat.com> wrote:
>> I've run up against reviewers who insist that all scripts and stylesheets
>> MUST be enqueued with a callback - as indeed the guidelines state. However,
>> the comment reply JS is enqueued without callback in the header of
>> TwentyTwelve and is considered the de-facto way to enqueue that.
>>
>> So, what is the exception? Is there something in the way that WordPress
>> loads templates and functionality that obviates the use of one style over
>> the other?
>>
>> Paul Appleyard
> If you *can* enqueue it in a callback, you should always do so. The
> enqueue system gives greater flexibility to child themes for adjusting
> things.
>
> However, as stated, the need for IE conditionals around scripts (not
> stylesheets) makes this impractical for the case in the original post.
> Therefore, for that particular case, I'd personally let it slide.
> There's no good way to do conditionals around scripts, and core
> doesn't appear to be looking to add a way to do it at present. And
> what with IE7 going into EOL, and what with IE10 ignoring these style
> of conditionals anyway, it's a problem that will eventually go away.
>
> Always enqueue in a callback, if possible. It's just good practice.
> Javascripts are sensitive to load order, generally speaking, and the
> enqueue system allows that to work properly.
>
> Here's something I learned today when investigating this: Did you know
> style enqueuing supports CSS media queries? I didn't.
>
> wp_enqueue_style( 'themename-phone-style',
> get_template_directory_uri().'/css/phone.css', array(), false, 'only
> screen and (max-device-width: 480px)' );
>
> Works great. :D
>
> -Otto
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers



More information about the theme-reviewers mailing list