WICG / document-policy

https://wicg.github.io/document-policy/
Other
19 stars 8 forks source link

Feature Policy: lazyload #6

Open ehsan-karamad opened 6 years ago

ehsan-karamad commented 6 years ago

Proposing a new feature policy for lazy-loading which will overwrite the default or specified behavior of lazyload attribute for <iframe> and <img>. The proposed name for the feature is lazyload.

The lazyload attribute (for an <iframe> or <img>) takes on three values of auto (decision of lazy-loading is deferred to the user agent), on (the contents will be loaded lazily), off (the contents will not be loaded lazily).

The proposed lazyload feature is a parameterized feature which takes one of the three values of:

The feature can also be set through container policies, for instance:

<iframe allow="lazyload *(force)" src="https://www.example.com" lazyload="off"></iframe>

which will enforce lazy loading for all domains. This would include https://www.example.com.

Malvoz commented 6 years ago

Just to clarify, I believe you missed the single quotes for the self and none values. And I would assume we set (auto|off|force) flags outside the single quotes? e.g. Feature Policy: lazyload 'self'(force) and the all (*) directive like so: Feature Policy: lazyload *(force).

ehsan-karamad commented 6 years ago

Thanks you are right. I fixed the missing single quotes for self.

alvarotrigo commented 5 years ago

Any way to detect whether the browser supports this feature or not? So we can use other lazy load libraries in case it doesn't ?

triblondon commented 5 years ago

Doesn't this feature have a really confusing name? I'm reading https://github.com/w3c/webappsec-feature-policy/blob/master/policies/lazyload.md, where it says:

Feature Policy: lazyload 'self' https://example.com would not allow synchronous loading for any