wordpress - wp_enqueue_script in action hook wp_print_scripts -


in wordpress documentation page function wp_enqueue_script, written:

note: function not work if called wp_head action, tags output before wp_head runs. instead, call wp_enqueue_script init action function (to load in pages), template_redirect (to load in public pages only), or admin_print_scripts (for admin pages only). do not use wp_print_scripts (see here explanation).

do not use wp_print_scripts action want highlight, simple google search on "how include javscript in wordpress". find of examples using wp_print_scripts action call wp_enqueue_script. , seems ok it.

so missing or misunderstanding here?


edit

the codex has been modified. says:

this function not work if called wp_head or wp_print_scripts actions, files need enqueued before actions run. see usage section correct hooks use.

yeah, been there lots of times. short answer guys print script requests wrong or folks suggest faster not use wp_enqueue_script load dynamically modernizr.load (yesnope.js) or other js loader lib.

my recommendation stick wp_enqueue_script best practice, if developing themes mobile, or extremely worried speed , not bloating browser requests, recommend load dynamically single js file (that may call wp_enqueue_script). consider inlining out , not loading jquery zepto.js or so.

many developers terrible practice of loading printed, not bad taste, terrible experienced theme developers might :s

for example thematic , several other blank themes rely on practices , truncates development speed childthemes.

if not sure wp_enqueue_script give wordpress codex read. thoroughly documented.

regards,


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -