-
Notifications
You must be signed in to change notification settings - Fork 97
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 Async and Defer boolean attributes for script resources #464
Conversation
/// Adds the specified boolean attribute to the next HTML element that is being rendered. Boolean attributes such as 'async' and 'defer' have no value. They are true when present and false otherwise | ||
/// </summary> | ||
/// <param name="name">The name of the HTML attribute.</param> | ||
void AddBooleanAttribute(string name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method should not be defined on this interface. You can create an extension method in your project.
Actually, I don't think that the Maybe we could have a global option that would render all script in the head with the |
I wanted get a good score on Google PageSpeed, even if there is no other benefit. It is an SEO thing. Currently, PageSpeed says:
I also wanted to load scripts via CDN with integrity hashes, and had put the script tag directly in the dotmaster. However, now I am able to specify the Integrity hash, thanks to another pull request, so I could probably load all of my scripts via the registration, and wire up the dependencies correctly. And have all the scripts loading at the bottom of the body, in the correct order. That may make pagespeed happy, although I would need to test. It doesn't specifically say this will solve the problem on their help page. https://developers.google.com/speed/docs/insights/BlockingJS But, if that is sufficient, perhaps this pull request isn't necessary as long as one is consistent in using the script registration. |
On Thu, 2017-12-28 at 20:14 +0000, symbiogenesis wrote:
I wanted get a good score on Google PageSpeed, even if there is no
other benefit. It is an SEO thing.
Ok, I think that we might render `defer` attribute by default for all
scripts. I'm pretty sure it would not break anything, could help with
the (stupid) statistics and it will certainly not harm the performance
(maybe it would get measurably better...). If you'd like that, we can
create a separate issue for that, it should be a easy fix.
I also wanted to load scripts via CDN with integrity hashes, and had
put the script tag directly in the dotmaster.
Do you have any info about integrity and performance? I actually think
that browsers *could* use that for caching (as content adressed blobs),
but I have not seen anything about that. It would mean that it would be
profitable to render these integrity checks even for local resources by
default.
|
Given that the entire point of DotVVM is to minimize the need to use javascript, it makes sense that we should, by default, assume that we have predictable control over how it is used and in that case we may be in a position to always defer javascript. Async probably not, although I'm not clear on what it truly means. I'll open a separate issue, as you suggest.
That is a brilliant idea, although I don't know how local caching works in browsers. May vary by browser. That would be a great question to ask Mozilla, Google, etc. |
The response from WHATWG is
|
And thanks for the info about the subresource integrity, I have also found an interesting study of the problem (https://hillbrad.github.io/sri-addressable-caching/sri-addressable-caching.html). It just seems that nothing is easy on web :) I'm closing this PR in favour of #528, thank you. |
No description provided.