Skip to content

Add amp-bind optimizer#1147

Merged
sebastianbenz merged 3 commits intoampproject:mainfrom
jridgewell:amp-bind
Feb 26, 2021
Merged

Add amp-bind optimizer#1147
sebastianbenz merged 3 commits intoampproject:mainfrom
jridgewell:amp-bind

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

@jridgewell jridgewell commented Feb 25, 2021

Copy link
Copy Markdown
Collaborator

@sebastianbenz sebastianbenz left a comment

Choose a reason for hiding this comment

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

Nice!

Two comments:

this.log_ = config.log.tag('OptimizeAmpBind');

// setup implementation only if placeholder generation is enabled
this.enabled_ = !!config.optimizeAmpBind;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should enable this by default.

Suggested change
this.enabled_ = !!config.optimizeAmpBind;
this.enabled_ = config.optimizeAmpBind !== false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Or did you intentionally leave this disabled until the validator changes are live?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, this is intentionally disabled until validator changes are live in AMP Cache. I was gonna follow up with a PR to enable it afterwards.

@sebastianbenz
Copy link
Copy Markdown
Collaborator

//cc @westonruter @schlessera for porting this to the PHP optimizer.

Co-authored-by: Sebastian Benz <sebastian.benz@gmail.com>
Copy link
Copy Markdown
Contributor Author

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

  • using data-amphtml-binding instead of I-amphtml-binding would mean that we wouldn't have to update the validator

I actually chose not to do this, since the attribute can only be valid in transformed outputs. Data attributes are always valid.

Working on that now.

this.log_ = config.log.tag('OptimizeAmpBind');

// setup implementation only if placeholder generation is enabled
this.enabled_ = !!config.optimizeAmpBind;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, this is intentionally disabled until validator changes are live in AMP Cache. I was gonna follow up with a PR to enable it afterwards.

@jridgewell
Copy link
Copy Markdown
Contributor Author

Tests added

Copy link
Copy Markdown
Collaborator

@sebastianbenz sebastianbenz left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants