[wp-trac] [WordPress Trac] #16024: Conditional Comments for JS

WordPress Trac noreply at wordpress.org
Tue Feb 17 14:10:55 UTC 2015


#16024: Conditional Comments for JS
--------------------------------------------------+-----------------------
 Reporter:  filosofo                              |       Owner:  azaozz
     Type:  enhancement                           |      Status:  closed
 Priority:  high                                  |   Milestone:  4.2
Component:  Script Loader                         |     Version:  3.1
 Severity:  normal                                |  Resolution:  fixed
 Keywords:  has-patch needs-testing dev-feedback  |     Focuses:  template
--------------------------------------------------+-----------------------

Comment (by jdgrimes):

 Replying to [comment:104 reypm]:
 > I  get lost at this point, are conditional scripts added to the CORE in
 4.1?

 No. If you look at the top of the ticket, you will see that the Milestone
 is 4.2. So this will be a part of 4.2.

 > I'm discussing some theme optimization [here][1] at SO and this ticket
 comes out but still don't get how to load scripts conditionally and I
 can't find any docs around it, can any give me some advice?

 I don't know if there are any docs for it, but one thing you can do is
 look at the tests committed in [31317]. They demonstrate how it works.

 > Also don't know if this is the right place but I should ask also for the
 right way to pass a variable from PHP side to jQuery as this [line][2]
 does, any advice on this doubts?

 You can use
 [http://codex.wordpress.org/Function_Reference/wp_localize_script
 wp_localize_script()] for this.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/16024#comment:105>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list