ampproject / ampproject/amp-toolbox

AMP Optimzier Appears To Be Stripping AMP iFrame Common Attributes

Open
#1,335 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
459
Forks
242
PR merge metrics
No merged PRs in 30d

Description

On the latest version of `@ampproject/toolbox-optimizer` (`v2.9.0`), it appears that certain iframe attributes are being stripped off the iframe. One in particular is the `heights` attribute.

Per the AMP docs `amp-iframe` [should include Common Attributes](https://amp.dev/documentation/components/amp-iframe-v1.0/?format=websites#common-attributes), with [heights](https://amp.dev/documentation/guides-and-tutorials/learn/common_attributes/?format=websites#heights) being one of the supported attributes for `amp-iframe`.

Is there any way around this or an option to not optimize iframe elements?

Many thanks!

--

Script to reproduce:
```
const AmpOptimizer = require('@ampproject/toolbox-optimizer');

const ampOptimizer = AmpOptimizer.create({});

const body = `




Test








`;

(async () => {
const optimizedHtml = await ampOptimizer.transformHtml(body);
console.log(optimizedHtml);
})();
```

Contributor guide

Open the contributing guide

Research direction

Run the supplied Node.js reproduction against @ampproject/toolbox-optimizer v2.9.0 and compare the amp-iframe attributes before and after transformation. Trace the optimizer path that handles amp-iframe elements; done means the heights attribute is preserved or a documented option exists to avoid iframe optimization.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript, nodejs
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.