-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add experimental amp-img -> img transformation (#859)
This commit introduces the data-hero attribute as a means to explicitly markup hero amp-img or amp-iframe elemenents. Other changes: * don't bail out if there are any kind of image preloads, instead check the img src to avoid duplicates * don't use loading=lazy * print warning if there are too many hero elements on a page
- Loading branch information
1 parent
9d67f26
commit 6f5d9dd
Showing
22 changed files
with
345 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...optimizer/spec/transformers/experimental/PreloadHeroImage/amp-iframe/expected_output.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<html> | ||
<head> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
<link rel="preload" href="http://example.com/foo.png" as="image" data-hero media="(max-width: 649px)"> | ||
</head> | ||
<body> | ||
<amp-iframe src="/test" layout="responsive" width="320" height="900" media="(max-width: 649px)"> | ||
<amp-img placeholder layout="fill" src="http://example.com/foo.png" i-amphtml-ssr><img class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async" src="http://example.com/foo.png"></amp-img> | ||
</amp-iframe> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
packages/optimizer/spec/transformers/experimental/PreloadHeroImage/amp-iframe/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<head> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
</head> | ||
<body> | ||
<amp-iframe src="/test" layout="responsive" width="320" height="900" media="(max-width: 649px)"> | ||
<amp-img placeholder layout="fill" src="http://example.com/foo.png"></amp-img> | ||
</amp-iframe> | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
...spec/transformers/experimental/PreloadHeroImage/amp-iframe_data-hero/expected_output.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
<head> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
<link rel="preload" href="hero.jpg" as="image" data-hero> | ||
</head> | ||
<body> | ||
<amp-iframe src="/no-hero" layout="responsive" width="320" height="900"> | ||
<amp-img placeholder layout="fill" src="no-hero.jpg"></amp-img> | ||
</amp-iframe> | ||
<amp-iframe data-hero src="/hero" layout="responsive" width="320" height="900"> | ||
<amp-img placeholder layout="fill" src="hero.jpg" i-amphtml-ssr><img class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async" src="hero.jpg"></amp-img> | ||
</amp-iframe> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
...optimizer/spec/transformers/experimental/PreloadHeroImage/amp-iframe_data-hero/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<head> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
</head> | ||
<body> | ||
<amp-iframe src="/no-hero" layout="responsive" width="320" height="900"> | ||
<amp-img placeholder layout="fill" src="no-hero.jpg"></amp-img> | ||
</amp-iframe> | ||
<amp-iframe data-hero src="/hero" layout="responsive" width="320" height="900"> | ||
<amp-img placeholder layout="fill" src="hero.jpg"></amp-img> | ||
</amp-iframe> | ||
</body> | ||
</html> |
Oops, something went wrong.