[wp-trac] [WordPress Trac] #60094: Performance Issue in Object Cloning using JSON.parse(JSON.stringify()) on Safari and Firefox

WordPress Trac noreply at wordpress.org
Mon Dec 18 12:49:36 UTC 2023


#60094: Performance Issue in Object Cloning using JSON.parse(JSON.stringify()) on
Safari and Firefox
--------------------------+-------------------------------------------
 Reporter:  omeri6        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.4
 Severity:  major         |   Keywords:  changes-requested needs-patch
  Focuses:  performance   |
--------------------------+-------------------------------------------
 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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60094>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list