[wp-trac] [WordPress Trac] #26210: Twenty Fourteen: Load Mediaelements.js when needed for Epemera Widget

WordPress Trac noreply at wordpress.org
Mon Nov 25 00:31:11 UTC 2013


#26210: Twenty Fourteen: Load Mediaelements.js when needed for Epemera Widget
------------------------------+------------------------------
 Reporter:  celloexpressions  |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Bundled Theme     |     Version:  trunk
 Severity:  normal            |  Resolution:
 Keywords:  needs-patch       |
------------------------------+------------------------------

Comment (by dimadin):

 This happens because content of the Twenty Fourteen Ephemera Widget (you
 missed "Ephemera" in both places :)) is stored to transient, while
 MediaElement.js is enqueued when shortcode callback function is called. So
 when widget content is served from transient, MediaElement.js isn't
 enqueued.

 In my patch there is one possible workaround. It checks if MediaElement.js
 has been enqueued during loop and if was, it saves that information to
 transient so that on next view when widget content is served from
 transient it checks for that transient and enqueues MediaElement.js.

 Con of this is that if MediaElement.js has been enqueued before loop it
 won't store transient while it might be needed in the future. This can be
 solved by only checking enqueuing status after loop but then
 MediaElement.js will always be enqueued even if not used by widget.
 Another con is that we'll have additional database request when
 MediaElement.js and object cache aren't used.

 Second possible solution can be to use `has_shortcode()` on each
 `post_content` during loop but that is more performance heavy (though only
 on empty cache) and MediaElement.js might not be used at all (overwritten
 by user).

 In all cases, this assumes that both script and styles are enqueued
 otherwise and that there aren't any other enqueues by user. Also, if there
 are other shortcodes with same behavior they wont be covered. This exposed
 important con of fragment caching that it enqueuing issue.

 So there must be some sacrifice and I'm leaving to decision makers to
 choose.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/26210#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list