ampproject / ampproject/amphtml

amp-consent - conditinally importing scripts based on consent.

Open
#33,288 4 comments 0 reactions 2 assignees Claimed by @micajuine-ho View on GitHub
P2: Soon Stale Type: Feature Request WG: performance
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

## Describe the new feature or change to an existing feature you'd like to see

I've been toying around with both and performance in general on our amp pages, and now that Core Web Vitals are a part of the Google Page Experience factor in google search, we have an added incentive to have the best performance possible.

In AMP consent, if I, as a user, reject tracking cookies, i have no need for loading `https://cdn.ampproject.org/v0/amp-analytics-0.1.js`, same goes if I've opted out of being having information shared, `https://cdn.ampproject.org/v0/amp-form-0.1.js` shouldn't be loaded, cause it isn't needed.

My suggestion would be to have the same `data-block-on-consent` attributes that we know from blocking amp components, able to block the import of the component scripts themselves, so that you can choose to only import the scripts you need, when you need them.

## Describe alternatives you've considered

There is not really a way to block conditionally scripts at the moment as far as i know.

## Additional context

@morsssss

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.