4 ms·
One way to help reduce overall weight of embeds (and improve the UX imho) is to block the ads - if you are able to leverage "Content Security Polices" on your p
by donohoe 2y ago
One way to help reduce overall weight of embeds (and improve the UX imho) is to block the ads - if you are able to leverage "Content Security Polices" on your pages.
Example META tag:
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' 'unsafe-inline' *.your-cdn-if-any.com
www.youtube.com *.googlevideo.com *.ytimg.com">
More info:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Co...
- 8organicbits 2y agoThat's clever, well worth its own blog post.
- swyx 2y agocan you tldr it? just one little meta tag defeats google's ad services? why dont we all slap it on our html templates?
- DavidPiper 2y agoThis seems to be allowing unsafe script injection from ONLY certain whitelisted urls, presumably excluding the url globs required for the ads. Haven't tested it, and not sure the full extent of pshc's sibling response either.
- pshc 2y agoPSA: Try not to chuck 'unsafe-inline' into your Content-Security-Policy thoughtlessly--it disables the anti-injection protections of CSP. There are safe ways to permit inline scripts, if you even need them. https://content-security-policy.com/ https://content-security-policy.com/