[theme-reviewers] html5.js enqueuing

Otto otto at ottodestruct.com
Wed Jun 12 17:34:42 UTC 2013


On Wed, Jun 12, 2013 at 10:21 AM, D5 Creation Support
<support at d5creation.com> wrote:
> One of our Themes named Easy was not approved today. One of the 2 required
> issues is enqueuing the html5.js from functions.php via callback function.
> The reviewer advised to do hard coding the html5.js from header.php as
> Twenty Twelve does.
>
> Our another Theme Design was not approved due to hard coding the html5.js
> from header.php rather than enqueuing.
>
> Which reviewer is correct? JavaScripts are required to enqueu via callback
> function as per the guideline.

Reviewers are human too. :)


For the specific case of scripts which need IE wrapper tags, I would
say that putting them directly in the header.php like this is
acceptable:

<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"
type="text/javascript"></script>
<![endif]-->

The $is_IE constant Frumph mentions relies on the HTTP_USER_AGENT
containing the "MSIE" string, and this is acceptable as well. However,
this is probably not the best approach for the html5.js in particular,
since IE 10 has html5 support and shouldn't need this JS file. So, I'd
actually say that, for now, the first method is preferable and a
reasonable exception to the guideline.


The scripts enqueueing system doesn't have a built in conditional
method, however stylesheets do. You can see this in use in
twenty-twelve :

wp_enqueue_style( 'twentytwelve-ie', get_template_directory_uri() .
'/css/ie.css', array( 'twentytwelve-style' ), '20121010' );
$wp_styles->add_data( 'twentytwelve-ie', 'conditional', 'lt IE 9' );


-Otto


More information about the theme-reviewers mailing list