[theme-reviewers] Javascript

Otto otto at ottodestruct.com
Mon Apr 25 06:42:33 UTC 2011


Actually, wp_enqueue_scripts is a better action hook to use.
wp_print_scripts also happens in the admin area, not just on the front
end. If you do want things in the admin area, then hook it to
admin_enqueue_scripts as well.

Also, enqueuing jQuery first is not necessary. If the other scripts
require it, then it gets automatically enqueued. That's the point of
the dependency system and the third parameter to wp_enqueue_script().

-Otto



On Sun, Apr 24, 2011 at 8:09 PM, Emil Uzelac <emil at themeid.com> wrote:
> Also, this is what I have in my functions.php for future references: (all
> added in footer area as well)
> /**
>  * A safe way of adding javascripts to a WordPress generated page.
>  */
> if (!is_admin())
>     add_action('wp_print_scripts', 'fit_js');
> if (!function_exists('fit_js')) {
>     function fit_js() {
>         wp_enqueue_script('jquery');
>         wp_enqueue_script('modernizr', get_template_directory_uri() .
> '/js/modernizr-min.js', array('jquery'), '1.7.0', true);
>         wp_enqueue_script('scripts', get_template_directory_uri() .
> '/js/scripts.js', array('jquery'), '1.0.4', true);
>         wp_enqueue_script('functions', get_template_directory_uri() .
> '/js/functions.js', array('jquery'), '1.0.4', true);
>     }
> }
> ----
> Emil Uzelac | ThemeID | T: 224-444-0006 | Twitter: @EmilUzelac | E:
> emil at themeid.com | http://themeid.com
> Make everything as simple as possible, but not simpler. - Albert Einstein
>
>
> On Sun, Apr 24, 2011 at 8:05 PM, Curtis McHale <curtis at curtismchale.ca>
> wrote:
>>
>> Alright I'll leave it to you.
>>
>> Curtis McHale
>> PH: 604.751.3482
>> http://www.curtismchale.ca
>> Linkedin: http://www.linkedin.com/in/curtismchale
>> Twitter: twitter.com/curtismchale
>>
>>
>>
>> On Sun, Apr 24, 2011 at 5:48 PM, Chip Bennett <chip at chipbennett.net>
>> wrote:
>>>
>>> I've got a few related Guidelines that were discussed on the Make site,
>>> that I need to add. I'll take a look at it tomorrow. :)
>>> Chip
>>>
>>> On Sun, Apr 24, 2011 at 7:41 PM, Curtis McHale <curtis at curtismchale.ca>
>>> wrote:
>>>>
>>>> Where would you suggest that specific mention of this is made in the
>>>> theme review guidelines? I'm happy to add it. As I read it alongside the
>>>> information on internationalization since if you include new JS you must use
>>>> the proper enqueue.
>>>>
>>>> Curtis McHale
>>>> PH: 604.751.3482
>>>> http://www.curtismchale.ca
>>>> Linkedin: http://www.linkedin.com/in/curtismchale
>>>> Twitter: twitter.com/curtismchale
>>>>
>>>>
>>>>
>>>> On Sun, Apr 24, 2011 at 5:38 PM, Chip Bennett <chip at chipbennett.net>
>>>> wrote:
>>>>>
>>>>> Yes, require that script to be enqueued properly.
>>>>> Chip
>>>>>
>>>>> On Sun, Apr 24, 2011 at 7:32 PM, Curtis McHale <curtis at curtismchale.ca>
>>>>> wrote:
>>>>>>
>>>>>> Are themes required to enqueue javascript with the built in WordPress
>>>>>> functions? I assume so but don't find specific reference to it in the theme
>>>>>> reviewer docs. The theme I'm currently reviewing includes jQuery from Google
>>>>>> CDN in the footer inside script tags.
>>>>>>
>>>>>> Curtis McHale
>>>>>> PH: 604.751.3482
>>>>>> http://www.curtismchale.ca
>>>>>> Linkedin: http://www.linkedin.com/in/curtismchale
>>>>>> Twitter: twitter.com/curtismchale
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> theme-reviewers mailing list
>>>>>> theme-reviewers at lists.wordpress.org
>>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> theme-reviewers mailing list
>>>>> theme-reviewers at lists.wordpress.org
>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> theme-reviewers mailing list
>>>> theme-reviewers at lists.wordpress.org
>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>
>>>
>>>
>>> _______________________________________________
>>> theme-reviewers mailing list
>>> theme-reviewers at lists.wordpress.org
>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>
>>
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>
>
> _______________________________________________
> 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