Skip to content
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

Allow picture element in noscript tag #18965

Closed
martindybal opened this issue Oct 25, 2018 · 8 comments
Closed

Allow picture element in noscript tag #18965

martindybal opened this issue Oct 25, 2018 · 8 comments
Assignees

Comments

@martindybal
Copy link

this is linked to the issue 1279

Now is allowed have <img>, <video>, and <audio> in <noscript>. It'll be nice to have some way how to create a fallback for webp format when user didn't have javascript allowed. I think it should also be allowed to have <picture> element in <noscript> .

There is a simple example:

<amp-img alt="The main square of Brno, Czech republic" width="1200" height="800" layout="responsive" src="images/brno.webp">
    <amp-img alt="The main square of Brno, Czech republic" fallback width="1200" height="800" layout="responsive" src="images/brno.jpg"></amp-img>
</amp-img>

<noscript>
    <picture>
        <source type="image/webp" sizes="images/brno.webp">
        <source type="image/jpeg" sizes="images/brno.jpg">
        <img alt="The main square of Brno, Czech republic" width="1200" height="800" sizes="" src="images/brno.jpg">
    </picture>
</noscript>
@aghassemi
Copy link
Contributor

SGTM

/to @Gregable

@Gregable
Copy link
Member

SGTM too.

In the meantime, I believe you can accomplish the same thing on a single img tag using srcset and sizes attributes.

@Gregable
Copy link
Member

Gregable commented Oct 25, 2018

Actually @aghassemi , is there a reason we couldn't allow something similar for <amp-img>, so this isn't a noscript-specific rule?

<picture>
   <source type="image/webp" srcset="images/brno.webp">
   <source type="image/jpeg" srcset="images/brno.jpg">
   <amp-img ...>
</picture>

Does this work? What would we need to do to make it work? It would address #3517 as well.

@Gregable
Copy link
Member

In the meantime, I believe you can accomplish the same thing on a single img tag using srcset and sizes attributes.

This is incorrect, I didn't initially realize you were doing this to select webp.

As an aside, your top amp-img approach, using a fallback, does work but isn't great. A non-webp browser will download both images, first the webp, then failing to decode it, the jpg. This actually adds latency for non-webp browsers, even if it does improve latency for webp browsers. The AMP Cache does do webp transcoding automatically for webp capable browsers, but this doesn't help on your own origin unless you can Vary based on Accept headers.

@martindybal
Copy link
Author

OK, so what is correct solution for support non-webp browser? There is same sample in the documentation https://www.ampproject.org/docs/design/responsive/responsive_design#providing-optimized-images maybe it should change or it should be mentioned there.

@Gregable
Copy link
Member

Ah, I didn't realize that this was being recommended. It's the only solution that works today that I know of, I'm just hoping @aghassemi or someone else has ideas for making this better.

Gregable pushed a commit that referenced this issue Oct 26, 2018
Resolves the noscript parts of #18965
Gregable added a commit that referenced this issue Oct 26, 2018
@aghassemi
Copy link
Contributor

yes, we essentailyl cover picture's main use-case via fallback on amp-img. I like some of the proposals on #3517 around this particularly #3517 (comment) but main use-case of falling back from WebP is covered so less of a priority

@aghassemi
Copy link
Contributor

Closing since noscript part was fixed by #18996 and rest is either covered or dup of #3517

warrengm pushed a commit to warrengm/amphtml that referenced this issue Oct 30, 2018
Enriqe pushed a commit to Enriqe/amphtml that referenced this issue Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants