[wp-trac] [WordPress Trac] #32307: Media library grid layout loading takes a (very) long time

WordPress Trac noreply at wordpress.org
Fri May 8 08:10:22 UTC 2015


#32307: Media library grid layout loading takes a (very) long time
--------------------------+-----------------------------
 Reporter:  jipmoors      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 '''Situation'''
 Corporate site with around 300 media items.
 CMS user notices me of the slow loading of the library.

 '''Research'''
 Grid layout loads in 13 seconds per `wp_prepare_attachment_for_js` request
 which results in 40 items with a request size of 450KB(!).
 List layout loads in 0.6 seconds results in 35 items with a request size
 of 12KB.

 '''Solution'''
 Disabling `get_compat_media_markup` takes the grid layout ajax requests
 back to 300-400ms with a size of 7-8kb.

 I have not been able to detect any functionality breaks on my
 environments, but since the name contains 'compat' this was not expected
 either.

 Unsure when/what is breaking when this would be disabled overall.

 '''Conclusion'''
 The grid layout adds a 'compat' variable with a lot of HTML content to
 each attachment.

 Which brings me to this piece of code:
 {{{
 if ( function_exists('get_compat_media_markup') )
                 $response['compat'] = get_compat_media_markup(
 $attachment->ID, array( 'in_modal' => true ) );
 }}}
 (wp-includes/media.php:2849)

 It seems that this function exists and is loaded (wp-
 admin/includes/media.php) so this will always be applied.

 There is no `if ( ! function_exists('get_compat_media_markup') )` around
 this function so overriding is not a possibility.

 Since there is no documentation surrounding this function I'm unsure how
 this is used. I'm sure that it is needed in some way or another but I hope
 it is not needed per item in the listing.

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


More information about the wp-trac mailing list