[wp-trac] [WordPress Trac] #51123: commonL10n and other JS globals removed without backwards compatibility

WordPress Trac noreply at wordpress.org
Sat Aug 29 11:34:29 UTC 2020


#51123: commonL10n and other JS globals removed without backwards compatibility
--------------------------------------+-------------------------
 Reporter:  kbjohnson90               |       Owner:  ocean90
     Type:  defect (bug)              |      Status:  reviewing
 Priority:  normal                    |   Milestone:  5.5.1
Component:  Script Loader             |     Version:  5.5
 Severity:  normal                    |  Resolution:
 Keywords:  needs-dev-note has-patch  |     Focuses:  javascript
--------------------------------------+-------------------------
Changes (by ocean90):

 * keywords:  needs-dev-note has-patch commit => needs-dev-note has-patch


Comment:

 Replying to [comment:32 peterwilsoncc]:

 Thanks for your work on the patch but I think it's not responsible to ship
 such a performance penalty in core for everyone.
 We're still looking at plugins which are using "private" globals which
 unfortunately were required to pass core translations to scripts. Just
 because they are there it doesn't mean that they are supported in any way.
 Otherwise there would have been some proper documentation. #50976 is a
 similar recent example for breaking something that wasn't intended to
 work.
 I also took a look at some of the plugins and some don't even define the
 necessary handle as a script dependencies neither do they the check for
 their existence before accessing the globals. They just expect them to be
 thereā€¦
 With regards to your example `commonL10n.warnDelete`, that's definitely
 something we shouldn't have to care about because the proper API would be
 using `window.showNotice.warn()`.

 Though, I do understand the issue that due to a few plugins other plugins
 or even core may not working properly anymore. And that's something we
 should fix by providing a graceful fallback as suggested in
 [attachment:"51123.diff"].
 I'm only wondering why the globals have all been defined in `common.js`?
 This will make the globals suddenly available on all screens. Wouldn't it
 be better to add them to each file where they were used previously?

 Unlike in PHP, the now deprecated and possible unused code would get
 shipped to the client on every (uncached) page load. So, we should include
 this with a clear deprecation policy. For example the current fallback
 will only be included in the next two major versions but you can install
 plugin X (similar to [https://wordpress.org/plugins/enable-jquery-migrate-
 helper/ Enable jQuery Migrate Helper]) to keep the fallback for a bit
 longer. We could use [https://developer.wordpress.org/block-
 editor/packages/packages-deprecated/ @wordpress/deprecated] for the
 extended message.

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


More information about the wp-trac mailing list