YSlow rule 8 (Make JavaScript and CSS External) vs valid html5
I like YSlow. And try use common sense when following it's rules. But for fun I'm trying to get my ASP.NET MVC site to score a 100. And I'm almost there (at 99 for the moment, e开发者_如何学Cven mirrored my site to a different server and change in about:config to simulate CDN).
And after testing I found out that to get the perfect score on rule 8 (Where i'm getting one point deducted for 2 inline scripts) you have to violate the HTML5 syntax rules (according to the w3c validator). I think this also apply to the HTML4 syntax rules.
For example, for no deductions (violates HTML5 syntax rules):
<script type="text/javascript" src="/ui/scripts/lib/core.js" />
And for valid HTML5 but with deductions on YSlow score:
<script type="text/javascript" src="/ui/scripts/lib/core.js"></script>
My hypothesis is that in some sense this is correct since the web-browser will scan for any script within the second example and not in the first (since the second is an open and close tag).
Does anyone know another way around this? Could one socre a perfect 100 and still have valid HTML5?
In both cases you can get rid of the type="text/javascript"
from the script tag. But yes, you need a closing script tag.
YSlow is incorrect here.
精彩评论