[wp-trac] [WordPress Trac] #56425: wp_localize_script assign to const and freeze instead of var to avoid reassignments

WordPress Trac noreply at wordpress.org
Wed Oct 12 18:57:14 UTC 2022


#56425: wp_localize_script assign to const and freeze instead of var to avoid
reassignments
-----------------------------------+------------------------------
 Reporter:  malthert               |       Owner:  (none)
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  Script Loader          |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:  javascript
-----------------------------------+------------------------------
Changes (by desrosj):

 * keywords:  has-patch => has-patch 2nd-opinion
 * focuses:  javascript, performance, coding-standards => javascript
 * version:  trunk =>


Comment:

 I think this is a difficult change to make.

 There are some valid scenarios where a plugin or theme would be adding to
 or adjusting values found in localized variables. If this were to change,
 it would potentially break backward compatibility for sites.

 I could see adding a way for a developer to tell `wp_localize_script()` to
 use `const` instead, but I think applying this change everywhere by
 default would cause more problems than it would solve.

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


More information about the wp-trac mailing list