Opened 12 months ago
Closed 12 months ago
#60094 closed defect (bug) (reported-upstream)
Performance Issue in Object Cloning using JSON.parse(JSON.stringify()) on Safari and Firefox
Reported by: | omeri6 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.4 |
Component: | External Libraries | Keywords: | needs-patch |
Focuses: | performance | Cc: |
Description
Elementor uses JSON.parse( JSON.stringify( object ) ) to clone objects.
Our users report significant performance issues on Safari and FireFox browsers
from version 6.4 of WordPress.
Our performance team confirmed that the loading time on Chrome is faster.
We have detected that the problem is associated with the following commit of corejs (used in wp-polyfill): https://github.com/zloirock/core-
js/commit/08ceeb13e78aeb366a3fcf481698ec05f77e7b2f
We managed to partially solve the issue by replacing the code with structuredClone( object ). However we couldn't replace all the occurrences of JSON.parse( JSON.stringify( object ) ) with structuredClone(), as structuredClone() doesn't accept methods.
Using alternative solutions to deep clone objects either increased loading time or had no effect.
After discussing the issue directly with corejs team, they suggested the following solution:
https://github.com/zloirock/core-js/issues/1316
Change History (4)
#1
@
12 months ago
- Component changed from General to External Libraries
- Keywords changes-requested removed
- Severity changed from major to normal
#2
@
12 months ago
Opened an issue: https://github.com/WordPress/gutenberg/issues/57247
Just so understand correctly, your suggestion is to change which core-js modules are provided by the
wp-polyfill
script because you ran into some issues withJSON.parse( JSON.stringify( object ) )
in your custom plugin?I think that would require a ticket on the Gutenberg repo as it seems to come from the
babel-preset-default
package.