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-consent - conditinally importing scripts based on consent. #33288

Open
SimonHogstromRonbol opened this issue Mar 16, 2021 · 3 comments
Open

Comments

@SimonHogstromRonbol
Copy link
Member

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

@kristoferbaxter
Copy link
Contributor

Adding @micajuine-ho and @erwinmombay.

I'm not sold on this approach, but we should experiment with the ability to lazyload these extensions based on consent.

@morsssss
Copy link
Contributor

Thanks for considering this, everyone! When @SimonHogstromRonbol pointed out to me that pages would be slowed by loading scripts for components that were blocked, I encouraged him to create this issue. I hope it's technically feasible...

@micajuine-ho
Copy link
Contributor

Thinking in terms of a simple single global consent, I wonder if there is an opportunity here for us to use the server to solve this, since with global consent there are only ever 3 consent states => Rejected (potentially only subset of elements/scripts are needed), Accepted (all elements/scripts needed), & No Decision Stored or Needed (all elements/scripts needed, potentially can be lazily loaded).

Not sure if this would work though since the consent decision is stored client side and so we would have to request different versions from the cache.

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

No branches or pull requests

5 participants