-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iframes: why we aren't doing them now, and when we might #18
Comments
Just going to drop the name Embed.ly here to note one of the places this came up recently. |
Edit: After re-reading Embedly's email to us, large portions of this comment may be incorrect. They may not be opposed to us sending markup/styling, just JavaScript. Which means we can deliver a responsive iframe-based response, it just can't have a dynamic aspect ratio. See #18 (comment) for a summary. Yeah, I nearly wrote a chapter on Embedly. They're a strange case. (They're also only an issue w/r/t our oEmbed endpoint, which shouldn't but can have a different embed strategy than the wizard.) According to the emails we've exchanged with them and their own docs, they expect nothing from the oEmbed endpoint but an This means they are, by design:
I don't see how we can square our needs with theirs. We either have to satisfy Embedly by delivering a non-responsive iframe tag via our oEmbed endpoint (which forces all of our oEmbed consumers to handle responsiveness on their own and still doesn't allow for variable aspect ratios), or shrug them off. |
Okay, so the problem is that we need to specify the aspect ratio at the time the iframe is inserted/defined. By the time a document is done processing, we should know the aspect ratio of the document and the individual pages (this is another tick mark in favor of storing the individual aspect ratios of pages and making them available). At that point, a document or page can be embedded either through automatic means (say an oembed request) or manually by a user requesting an embed code and saving that in their CMS. In the first case, we have full control over the definition of the iframe and it would be possible to specify what the height/width/aspect ratio for a document should be. (note this is a change with non-trivial consequences as it would require making a database call in order to identify the max|min|avg aspect ratio) In the latter case, we would only have one shot at getting the aspect ratio right if we were to bake that information directly into an embed code and handing it off to the user. That means that if the document were modified, the aspect ratio would not be updated. That said, our current embed codes do not codify that information directly (except at the user's request). And it might be viable to continue doing that. |
I would love if we could depend on the aspect ratio at load time remaining static. But see the I'm fully in support of calculating/storing individual page aspect ratios. Even if we never lick the above, it's still useful in generating sensible default dimensions for the embed code. |
Summary of our options:
❌ Responsive
✅ Responsive
✅ Responsive |
We won't be baking in our own responsive iframe solution for a while longer (see #18), and the test page was inadvertently telegraphing too much intent. Move to a subpage.
TL;DR: We plan to support iframes as soon as we are happy with an embed design that maintains a static aspect ratio.
This issue details our difficulty using iframes for our particular embed needs, and why we're punting on them for now. It's not impossible, just enough of a lift to move out of MVP.
A common request and a strong internal desire is for our embeds to be delivered via iframes. This has significant advantages: the iframe is a silo within which our JS/CSS are safe from the parent page (and vice versa), and as a single HTML tag it's generally portable:
Wouldn't that be nice. Unfortunately, it's not responsive at all. This is usually solved with a little HTML wrapping and some CSS, so you end up with something like this:
A little gross, but at least it doesn't require any JS on the parent page. Unfortunately, it only works if the embed maintains a static aspect ratio, like a video. For those with aspect ratios that could change while the embed is being used or resized, like ours, you have to whip out the JS:
What would this script have to do?
That last one is the doozy and why Pym exists.
– begin aspect ratio tangent –
It's useful to ask: what causes us to have a variable aspect ratio? Why can't we calculate the ideal aspect ratio for a given resource when generating its embed code and force ourselves to keep it? Here's what causes aspect ratio changes:
width:height
is400px:800px
for an aspect ratio for1:2
. Now shrink the page to 200px wide and 380px tall; total embed is200px:420px
for an aspect ratio of1:2.1
.There are design compromises for each of these problems; we just have to decide if they're worthwhile.
– end aspect ratio tangent –
### So what are we going to do?
We'll start with the progressive enhancement model used by Twitter and others, where the initial embed code is effectively a
noscript
replacement plus some JS:The script then parses the faux-noscript and replaces it with the real direct-embed markup.
When will we add iframes?
noscript
, or basically a non-responsive and potentially mis-aspect-ratioed representation of the embed, but which we are satisfied with as the worst-case fallbackThe text was updated successfully, but these errors were encountered: