[wp-trac] [WordPress Trac] #21547: Enable 'delocalization' of scripts

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 11 07:47:09 UTC 2012


#21547: Enable 'delocalization' of scripts
-------------------------+------------------------------
 Reporter:  gkb6891      |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------

Comment (by westi):

 Replying to [comment:2 gkb6891]:
 > Replying to [comment:1 scribu]:
 > > That patch looks fine.
 > >
 > > The question is: why would you need to 'delocalize' a script?
 >
 > It's not necessarily for internationalization. In my case, at
 Automattic, the WordPress.com plugin I was working on uses
 wp_localize_script to pass dynamic properties to a static javascript file.
 >
 > Here's the specific scenario: we run multiple a/b tests each of which
 needs some dynamic parameters passed to a static javascript file. Each of
 these a/b tests enqueues the static javascript file if it's not already
 been enqueued.
 >
 > The current implementation of wp_localize_script simply creates a new JS
 object each time it's called. This often leads to duplicate objects or
 overwriting existing objects. A developer (like me in this case) might
 want to modify the existing JS object instead of creating a new one. It's
 easy to simply delocalize the script by passing the handle and calling
 wp_localize_script one more time.

 I'm not yet convinced this is a good justification for doing this.

 I'm pretty sure we can re-work your code to make it not need this, we can
 talk about it later.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21547#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list