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

Unable to parse the static (server-rendered) `<head>`. Falling back to `document.head`

rviscomi opened this issue · comments

image

I'm consistently getting this warning on https://web.dev/ when the "prefer static head" option is enabled.

On one hand, this page is sending HTML without any <head> element:

image

Maybe this is some kind of extreme minification setting. But because capo can't extract the static head from the markup, it seems ok to fall back.

On the other hand, the browser is forgiving enough to make everything between html and body the head, so maybe capo could be more flexible and try falling back to that.

So one idea would be to check for the static head, fall back to the implicit static head, and if all else fails, fall back to the dynamic head. If we ever get into this middle state like on web.dev, there should be a different warning message about the lack of any discernible head in the static markup. It's not invalid but it's sketchy.

Would be good to understand other notable examples of this warning in the wild. (please comment if you have one)