Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add render blocking post #12

Merged
merged 10 commits into from
Jul 13, 2021
Merged

Add render blocking post #12

merged 10 commits into from
Jul 13, 2021

Conversation

siakaramalegos
Copy link
Owner

No description provided.

Copy link

@rik rik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool!

src/posts/render-blocking-resources.md Outdated Show resolved Hide resolved
src/posts/render-blocking-resources.md Outdated Show resolved Hide resolved
src/posts/render-blocking-resources.md Outdated Show resolved Hide resolved
<img src="/img/critical_render_path_JS_karamalegos.svg"
alt="HTML encounters a synchronous script in the head which stops the parser"
width="595" height="862">
<figcaption>Synchronous JavaScript (no async or defer) will block the HTML parser both for download and execution (<a href="#critical-render-path-js">link</a>)</figcaption>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the diagrams but it's inaccurate because the CSS will be downloaded before the script executes. This is because of speculative parsing that will look ahead to discover resources, even if the HTML parser is blocked.

It's super tricky to represent that in a diagram though.

https://andydavies.me/blog/2013/10/22/how-the-browser-pre-loader-makes-pages-load-faster/
https://webkit.org/blog/166/optimizing-page-loading-in-web-browser/
whatwg/html#5624

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have an idea for that. I'm wondering if that means the CSSOM construction is not blocked? I feel like it should be though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not explored this deeply enough recently to know the answer, sorry.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again. Just edited the diagram and pushed up all the changes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good diagram: more accurate without going too deep into speculative parsing.

I think the <figcaption> still needs updating though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you've updated the other figcaption (and that's a good edit). This one still mentions that it blocks downloads.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presumed a non-async script would block the speculative parser as well as the HTML parser because the script might change the content?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, the speculative parser was created exactly for sync scripts and in particular document.write() (see the links I shared). It is called speculative because it could download resources that won't be needed once the real parser as done its job. Bugs aside, the idea works well in practice because we rarely use document.write to comment out a section of HTML.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this one I actually meant the parser is blocked during download and execution of the JavaScript. Not that it blocks other files for download. Is this more clear?

Synchronous JavaScript (no async or defer) will block the HTML parser during both download and execution of the JavaScript

Copy link

@rik rik Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

While synchronous JavaScript (no async nor defer) is being downloaded and executed, the HTML parser is blocked

@siakaramalegos siakaramalegos merged commit a84f80a into main Jul 13, 2021
@siakaramalegos siakaramalegos deleted the render-block-post branch July 13, 2021 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants