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

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 11 07:22:21 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 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, 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 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. 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.

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


More information about the wp-trac mailing list