<div dir="ltr">What do you mean by &quot;put before&quot; your enqueued scripts? Can you give a use-case/example?<div><br></div><div style>If you need to *print* a script before other enqueued scripts, you can do several things. Here are a couple:</div>
<div style><br></div><div style>1. Make the script a *dependency* of the later scripts</div><div style>2. Hook the script into wp_head, at priority 0.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 22, 2013 at 1:34 PM, Abhik Biswas <span dir="ltr">&lt;<a href="mailto:abhik@itsabhik.com" target="_blank">abhik@itsabhik.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div>Okay,<br></div>So, what if I need to put something *before* my enqueued scripts, what should I use?<br>
<br></div>Is this the right way?<br><br></div>function my_scripts() { ?&gt;<br>
&lt;script type=&quot;text/javascript&quot;&gt;<br>........<br></div>&lt;/scripts&gt;<br><br></div>&lt;?php }<br></div>add_action (&#39;wp_enqueue_scripts&#39;, &#39;my_scripts&#39;, 5 );<br><br></div><br><br><br><br>function my_enqueued_scripts() {<br>

<br></div> wp_enqueue_script (&#39;myscript&#39;, ...... myotherscript.js....., &#39;&#39;);<br><br>}<br>add_action (&#39;wp_enqueue_scripts&#39;, &#39;my_enqueued_script&#39;, );<br></div><div class="HOEnZb"><div class="h5">
<div class="gmail_extra"><br><br>
<div class="gmail_quote">On Tue, Jan 22, 2013 at 11:56 PM, Otto <span dir="ltr">&lt;<a href="mailto:otto@ottodestruct.com" target="_blank">otto@ottodestruct.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

The question itself is slightly confusing, because it kinda depends on<br>
the purpose...<br>
<br>
For the front-end of the site, the wp_print_scripts action is actually<br>
executed from the wp_print_head_scripts() function.<br>
<br>
The wp_print_head_scripts() function is actually hooked to the wp_head<br>
action, like so:<br>
add_action( &#39;wp_head&#39;, &#39;wp_print_head_scripts&#39;, 9 );<br>
<br>
Same goes for wp_enqueue_scripts. The wp_enqueue_scripts action is in<br>
the wp_enqueue_scripts() function which is called like so:<br>
add_action( &#39;wp_head&#39;, &#39;wp_enqueue_scripts&#39;, 1 );<br>
<br>
So the answer is different depending on whether you consider the<br>
action to have occurred when the action is called or when the action<br>
has returned.<br>
<br>
The long and the short of it is that both enqueuing and printing of<br>
scripts happen inside the wp_head() call. So the question of ordering<br>
isn&#39;t something that external code really needs to consider. Instead,<br>
you need to know that you should add scripts on wp_enqueue_scripts,<br>
and remove scripts on wp_print_scripts (as this is the last possible<br>
moment to remove them before they get printed to the output).<br>
<span><font color="#888888"><br>
-Otto<br>
</font></span><div><div><br>
<br>
On Tue, Jan 22, 2013 at 12:16 PM, Michael Fields &lt;<a href="mailto:michael@mfields.org" target="_blank">michael@mfields.org</a>&gt; wrote:<br>
&gt; Here&#39;s a simple way to test this:<br>
&gt;<br>
&gt; &lt;?php<br>
&gt; function mfields_test_some_hooks() {<br>
&gt;         static $i = 1;<br>
&gt;         var_dump( $i . &#39; - &#39; . current_filter() );<br>
&gt;<br>
&gt;         $i++;<br>
&gt; }<br>
&gt;<br>
&gt; add_action( &#39;wp_head&#39;,            &#39;mfields_test_some_hooks&#39; );<br>
&gt; add_action( &#39;wp_print_scripts&#39;,   &#39;mfields_test_some_hooks&#39; );<br>
&gt; add_action( &#39;wp_enqueue_scripts&#39;, &#39;mfields_test_some_hooks&#39; );<br>
&gt; ?&gt;<br>
&gt;<br>
&gt; I get the following order:<br>
&gt;<br>
&gt; 1 - wp_enqueue_scripts<br>
&gt; 2 - wp_print_scripts<br>
&gt; 3 - wp_head<br>
&gt; _______________________________________________<br>
&gt; theme-reviewers mailing list<br>
&gt; <a href="mailto:theme-reviewers@lists.wordpress.org" target="_blank">theme-reviewers@lists.wordpress.org</a><br>
&gt; <a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org" target="_blank">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
<br></blockquote></div><br></div>