rviscomi / capo.js

Get your <head> in order

Home Page:https://rviscomi.github.io/capo.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Asynchronous or Synchronous scripts?

dougouverson opened this issue · comments

According to https://rviscomi.github.io/capo.js/user/rules/#-8-asynchronous-scripts

<script async src>

The following scripts were included in the Asynchronous scripts order:

<script type="text/javascript"> document.documentElement.className = 'js'; </script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="" id="jquery-migrate-js"></script>

I thought maybe they should have been included in Synchronous scripts?

Could you share a reproducible example using the demo page?
https://rviscomi.github.io/capo.js/user/demo/?url=https://www.example.com/

If I plug those scripts into the HTML demo, I do see them correctly attributed as sync scripts (level 6):

image

My bad. I had it backward. I was thinking that the following scripts would be Asynchronous:

<script data-cfasync="false">...</script>
<script data-cfasync="false" data-pagespeed-no-defer="">...</script>

Page 1

Yeah I was going to ask what the problem was 😁
Are you seeing async (level 8) anywhere else or can we close this as WAI?

Not that I can see:

Page 2
Page 3

Ok thanks, looks like this is WAI

I'm sorry, what is WAI?

Working as intended

Was I mistaken with <script data-cfasync="false"> being Asynchronous? It's in Synchronous currently.

Yeah, asynchronous scripts are specifically defined as script[async], but that script has a data attribute coincidentally named data-cfasync. Data attributes are just ways to stuff information into DOM elements and browsers don't behave any differently when they're encountered.

Thanks, Rick, for the explanation!

WAI !