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

Amp Ad Fast Fetch allow amp-image prefetch #11391

Merged
merged 4 commits into from Sep 25, 2017
Merged

Amp Ad Fast Fetch allow amp-image prefetch #11391

merged 4 commits into from Sep 25, 2017

Conversation

keithwrightbos
Copy link
Contributor

Allow for prefetching amp-image src resources after AMP creative validation but in advance of layoutCallback in order to reduce time to render/load for down page slots.

cc/ @ampproject/a4a

@keithwrightbos keithwrightbos self-assigned this Sep 22, 2017
a4a.onLayoutMeasure();
return a4a.layoutCallback().then(() => {
expect(doc.querySelector('link[rel=preload]' +
'[href="https://prefetch.me.com?a=b"]')).to.be.ok;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String continuation onto next line should be indented 4 spaces, correct? (I suspect this is a case of the indentation being wrong but the file is omitted by the linter)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It passes gulp lint and I am fairly positive it is enforced on test files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, nvm then

@@ -106,7 +106,8 @@ export let SizeInfoDef;
/** @typedef {{
minifiedCreative: string,
customElementExtensions: !Array<string>,
customStylesheets: !Array<{href: string}>
customStylesheets: !Array<{href: string}>,
ampImages: Array<string>|undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gulp check-types didn't like this. I suggest:

ampImages: (Array<string>|undefined),

See:

* duration: (time|undefined),

Copy link
Contributor

@jonkeller jonkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gulp doesn't like typedef

@@ -738,6 +739,9 @@ export class AmpA4A extends AMP.BaseElement {
// Preload any fonts.
(creativeMetaDataDef.customStylesheets || []).forEach(font =>
this.preconnect.preload(font.href));
// Preload any AMP images.
(creativeMetaDataDef.ampImages || []).forEach(image =>
isSecureUrl(image) && this.preconnect.preload(image));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @dvoytenko to confirm, we are ok to preload an array of images?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. We discussed. Should be ok as long as this list is not super long.

@keithwrightbos keithwrightbos merged commit bb6cc2a into ampproject:master Sep 25, 2017
@keithwrightbos keithwrightbos deleted the a4a_image_prefetch branch September 25, 2017 18:14
rsimha added a commit that referenced this pull request Sep 26, 2017
@@ -733,6 +734,9 @@ export class AmpA4A extends AMP.BaseElement {
// Preload any fonts.
(creativeMetaDataDef.customStylesheets || []).forEach(font =>
this.preconnect.preload(font.href));
// Preload any AMP images.
(creativeMetaDataDef.images || []).forEach(image =>
isSecureUrl(image) && this.preconnect.preload(image));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who controls the origin of these images? How do we know we're not preconneting to a tracking service?

throw new Error(errorMsg);
}
});
}
if (isArray(metaDataObj['images'])) {
// Load maximum of 5 images.
metaData.images = metaDataObj['images'].splice(0, 5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not match the comment! #slice is not #splice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this will work since #splice returns the removed elements. But still, not the canonical use, #slice would be better here.

@@ -733,6 +734,9 @@ export class AmpA4A extends AMP.BaseElement {
// Preload any fonts.
(creativeMetaDataDef.customStylesheets || []).forEach(font =>
this.preconnect.preload(font.href));
// Preload any AMP images.
(creativeMetaDataDef.images || []).forEach(image =>
isSecureUrl(image) && this.preconnect.preload(image));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should pass in an as value. Otherwise it'll be downloaded 2x in Safari.

dmvjs pushed a commit to dmvjs/amphtml that referenced this pull request Jan 31, 2018
* Amp Ad Fast Fetch allow amp-image prefetch

* type check fix

* feedback from @dvoytenko
dmvjs added a commit to dmvjs/amphtml that referenced this pull request Feb 6, 2018
…o jr/amp-addthis

* 'jr/amp-addthis' of https://github.com/dmvjs/amphtml: (54 commits)
  Add required logic for view/engagement analytics without an iframe
  Lojson call refactor; saving WIP
  Code review cleanup
  Make all images in AMP have the `async` attribute. (ampproject#11366)
  skip test (ampproject#11459)
  Fix having multiple Criteo standalone ads on one page (ampproject#11285)
  add `bt` (binary type) query param to error reporting query string (ampproject#11452)
  Enables vendor iframe to send response to creative (ampproject#11306)
  Remove noisy 3p error for user error reporting (ampproject#11382)
  Ramp Fast Fetch crypto verifier experiment to 10% (ampproject#11447)
  Updates doubleclick impl to include docs on fluid (ampproject#11437)
  Revert "Add a visual diff test for amp-pinterest" (ampproject#11442)
  Ramp experiment down to 0 (ampproject#11441)
  Updated changelog with recent validator release (ampproject#11440)
  Remove pfx parameter from Doubleclick Fast Fetch reuests (ampproject#11439)
  Allow element to accept custom share attributes (with fallback); remove other ownerDocument refs
  Add wait code for amp.article.html (ampproject#11429)
  fix inabox-viewport test (ampproject#11428)
  Remove camelcase from data attributes
  Amp Ad Fast Fetch allow amp-image prefetch (ampproject#11391)
  ...
dmvjs added a commit to dmvjs/amphtml that referenced this pull request Feb 6, 2018
…o jr/amp-addthis

* 'jr/amp-addthis' of https://github.com/dmvjs/amphtml: (54 commits)
  Add required logic for view/engagement analytics without an iframe
  Lojson call refactor; saving WIP
  Code review cleanup
  Make all images in AMP have the `async` attribute. (ampproject#11366)
  skip test (ampproject#11459)
  Fix having multiple Criteo standalone ads on one page (ampproject#11285)
  add `bt` (binary type) query param to error reporting query string (ampproject#11452)
  Enables vendor iframe to send response to creative (ampproject#11306)
  Remove noisy 3p error for user error reporting (ampproject#11382)
  Ramp Fast Fetch crypto verifier experiment to 10% (ampproject#11447)
  Updates doubleclick impl to include docs on fluid (ampproject#11437)
  Revert "Add a visual diff test for amp-pinterest" (ampproject#11442)
  Ramp experiment down to 0 (ampproject#11441)
  Updated changelog with recent validator release (ampproject#11440)
  Remove pfx parameter from Doubleclick Fast Fetch reuests (ampproject#11439)
  Allow element to accept custom share attributes (with fallback); remove other ownerDocument refs
  Add wait code for amp.article.html (ampproject#11429)
  fix inabox-viewport test (ampproject#11428)
  Remove camelcase from data attributes
  Amp Ad Fast Fetch allow amp-image prefetch (ampproject#11391)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants