5 ms·
You misunderstand the 8 second CSS animation in the AMP boilerplate. Here's the code (simplified): <style> body { animation:-amp-start 8s steps(1,end) 0s
by gregable 7y ago
You misunderstand the 8 second CSS animation in the AMP boilerplate. Here's the code (simplified):
<style>
body { animation:-amp-start 8s steps(1,end) 0s 1 normal both}
@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
</style>
<noscript>
<style amp-boilerplate>
body{animation:none}
</style>
</noscript>
See the noscript section: if javascript is disabled, the CSS displays the body immediately. If Javascript is enabled, but for some reason the AMP javascript fails to load, after 8 seconds, the page is displayed anyway. When the AMP Javascript loads (a single js file, one request, typically already in the users cache), the javascript displays the page immediately. The page is probably somewhat broken without the javascript loading, but the 8s is a fallback, not code to slow down non-javascript browsers.
The only two cases where the 8s is relevant are: the network connection is so bad that the javascript file fails to load within 8s and the useragent has explicitly blocked the one javascript file on the page, without blocking javascript overall.
- munk-a 7y agoThis will hit a lot of people on the web today that have given up on a blanket block on JS (because a lot of pure text content simply fails to render without JS, yaaaaay) but do have a blanket blacklist on JS assets and whitelist requests on a need basis.
- 4ntonius8lock 7y agoAs intended. We desperately need some anticompetitive scrutiny on google. Unfortunately... https://www.opensecrets.org/orgs/summary.php?id=d000067823 https://www.opensecrets.org/orgs/summary.php?id=d000067823
- JoshMnem 7y agoThe 8-second delay is there to punish users who block JavaScript that is loaded from Google's servers (with ad-blockers) but still have JavaScript enabled.
- esrauch 7y agoI think that's a bit unnecessarily tin-foil-hat. If they didn't put in the 8 second css rule it would just show blank for those users right? So adding that rule is making it work at all instead which doesn't sound like "there to punish them".
- JoshMnem 7y agoIt's the other way around -- AMP pages show a blank page for 8 seconds for people with ad-blockers because of that CSS rule.
- gregable 7y agoThe behavior you describe occurs if the useragent blocks the URL https://cdn.ampproject.org/v0.js https://cdn.ampproject.org/v0.js which does not have anything to do with ads or analytics. Certainly an ad blocker can be used to block any URL, but I don't know of any that block this one by default. If there are any, let me know and I'm happy to file issues to get that fixed! If a user chooses to block this particular resource which the page needs to load, then the page still loads after 8s. Similarly, if the site owner chooses, they can run the AMP Toolbox optimizer (https://www.npmjs.com/package/@ampproject/toolbox-optimizer https://www.npmjs.com/package/@ampproject/toolbox-optimizer) which lays out the page server-side and removes this CSS flash for most documents. Some documents can't be laid out until the viewport size is known.
- JoshMnem 7y agoPeople who block JS by default but who don't want to completely turn off JavaScript encounter that 8-second delay. (I'm using "ad-blocker" loosely -- it refers to any kind of tool that blocks ads and tracking. On my computer, it's blocked at the hosts level in addition to an add-on.) Some people don't want to load resources from Google's servers, and they shouldn't be punished for it. That JS file isn't needed for AMP pages to load. People don't need to load JS to read text and view images. I don't think there is any reasonable argument to have any users hit an 8-second delay.