[theme-reviewers] Printing JavaScript in footer

Otto otto at ottodestruct.com
Sat Aug 3 18:22:06 UTC 2013


I'm with Justin on this one. Enqueueing shouldn't be needed for
something like this.

However, I would like the line:
add_action('wp_footer', 'flex_init');

To be in a function that is wrapped in an if (!function_exists)
wrapper, and have that hooked to after_setup_theme. A normal pluggable
"init" function, basically. With this, the function can be overridden
by a child theme if needed.

-Otto


On Sat, Aug 3, 2013 at 1:17 PM, Justin Tadlock <justin at justintadlock.com> wrote:
> Printing JS like that should be perfectly fine.  I see no reason to load 3
> lines of jQuery as a completely separate file and probably wouldn't consider
> it best practice to do so.
>
>
> On 8/3/2013 12:09 PM, Edward Caissie wrote:
>
> I would strongly lean towards REQUIRED ... mostly for consistency when and
> where scripts are enqueued.
>
> Other than that I would say RECOMMENDED as a best practice ideal at a
> minimum.
>
> Edward Caissie
> aka Cais.
>
>
> On Sat, Aug 3, 2013 at 1:02 PM, Chip Bennett <chip at chipbennett.net> wrote:
>>
>> Agree, but it's added as a callback to wp_footer() - so is it a
>> *recommended* or *required* aspect that it be enqueued via
>> wp_enqueue_script()?
>>
>>
>> On Sat, Aug 3, 2013 at 12:03 PM, Edward Caissie <edward.caissie at gmail.com>
>> wrote:
>>>
>>> That script can, and more importantly *should* be enqueued.
>>>
>>> Edward Caissie
>>> aka Cais.
>>>
>>>
>>> On Sat, Aug 3, 2013 at 11:54 AM, Harish <me at harishchouhan.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>>
>>>>
>>>> I have seen many premium themes doing this. Not a good practise so I
>>>> would not recommend it.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Harish Chouhan
>>>>
>>>>
>>>>
>>>> Visit me at - www.harishchouhan.com
>>>> Phone: +91-9833661410 | Email: me at harishchouhan.com
>>>>
>>>>
>>>>
>>>> From: theme-reviewers
>>>> [mailto:theme-reviewers-bounces at lists.wordpress.org] On Behalf Of Ola Laczek
>>>> Sent: Sat 03 August 13 09:16 PM
>>>> To: theme-reviewers at lists.wordpress.org
>>>> Subject: [theme-reviewers] Printing JavaScript in footer
>>>>
>>>>
>>>>
>>>> Hello!
>>>>
>>>>
>>>>
>>>> I'm reviewing a theme that prints javascript in the footer from
>>>> functions.php like this:
>>>>
>>>>
>>>>
>>>> add_action('wp_footer', 'flex_init');
>>>>
>>>> function flex_init() {
>>>>
>>>>      echo '<script type="text/javascript">
>>>>
>>>>     jQuery(document).ready(function() {
>>>>
>>>>         jQuery("#slider").flexslider();
>>>>
>>>>      });
>>>>
>>>>      </script>';
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> Is this ok, or should I tell this person to create separate javascript
>>>> file, put this code there and enqueue like other scripts?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Best regards,
>>>> Ola Łączek
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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