Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#26210 closed defect (bug) (fixed)

Twenty Fourteen: Load MediaElement.js when needed for Ephemera Widget

Reported by: celloexpressions's profile celloexpressions Owned by: lancewillett's profile lancewillett
Milestone: 3.8 Priority: low
Severity: normal Version: 3.8
Component: Bundled Theme Keywords:
Focuses: Cc:

Description

When Mediaelements.js isn't needed for anything in post content on a given screen, it isn't loaded. But if a user features Audio and/or Video-formatted posts with the Twenty Fourteen Empemera widget, we need it (both for our styling and the functionality compatibility).

Might be a core issue (which we should fix).

Attachments (3)

26210.patch (1.6 KB) - added by dimadin 11 years ago.
26210.diff (1.9 KB) - added by obenland 11 years ago.
26210.2.diff (1.0 KB) - added by obenland 11 years ago.

Download all attachments as: .zip

Change History (12)

#1 follow-up: @dimadin
11 years ago

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.

@dimadin
11 years ago

#2 in reply to: ↑ 1 @celloexpressions
11 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed
  • Summary changed from Twenty Fourteen: Load Mediaelements.js when needed for Epemera Widget to Twenty Fourteen: Load MediaElement.js when needed for Ephemera Widget

Replying to dimadin:

you missed "Ephemera" in both places :)

I guess that's what happens when I try to make/comment on more than three tickets at the same time :)

#3 @lancewillett
11 years ago

  • Milestone changed from Awaiting Review to 3.8

#5 @lancewillett
11 years ago

  • Keywords needs-patch added; has-patch dev-feedback removed

@obenland is working on removing the widget caching, which will close this ticket and #26335.

#6 @lancewillett
11 years ago

  • Priority changed from normal to low

@obenland
11 years ago

#7 @lancewillett
11 years ago

  • Owner set to lancewillett
  • Resolution set to fixed
  • Status changed from new to closed

In 26577:

Twenty Fourteen: remove transient usage in Ephemera widget to fix caching issues. Props obenland, closes #26210 and #26335.

#8 @lancewillett
11 years ago

  • Keywords needs-patch removed

@obenland
11 years ago

#9 @lancewillett
11 years ago

In 26580:

Twenty Fourteen: remove more widget cache code, props obenland. See #26210.

Note: See TracTickets for help on using tickets.