ampproject / ampproject/amphtml

Stop cache rewriting of URLs in style attributes of templates

Open
#19,479 6 comments 0 reactions 1 assignee Assigned to @jridgewell View on GitHub
INTENT TO IMPLEMENT P2: Soon Stale WG: runtime
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Background

Currently, URLs inside the `style` attribute of `` descendants are rewritten as AMP cache URLs (on pages served from AMP cache). For example:

```html

```

```html


```

This can cause bugs when the URLs have template variables, e.g. #19439. To avoid these bugs and [improve consistency with existing behavior](https://github.com/ampproject/amphtml/blob/master/spec/amp-cache-modifications.md#all-image-urls-are-rewritten-as-amp-cache-urls-except-those-in-amp-mustache-template), we're planning to disable cache rewriting of these URLs.

This is a potentially breaking change for pages served from AMP cache.

### Am I affected by this change?

If you're using relative URLs inside `style` attributes for descendants of `` elements, yes.

Otherwise, no.

### I'm affected. How do I fix it?

Change your relative URLs to be absolute. E.g. for the above example:

```html


```

### When will this change be made?

There's no timeline yet. First, we'll add code to detect these cases at runtime and output a user error. We'll update this issue with sufficient forward notice per the [deprecations policy](https://github.com/ampproject/amphtml/blob/master/spec/amp-versioning-policy.md#deprecations) if a formal deprecation is warranted.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.