Question

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, even 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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top