Shazwazza / ClientDependency

DEPRECATED. A library for managing CSS & JavaScript dependencies and optimization in ASP.Net
139 stars 65 forks source link

Remove type attribute from script tag #134

Closed kledung closed 5 years ago

kledung commented 6 years ago

Hi! I wan't to remove the type attribute (type="text/javascript") from the script tag since it's unnecessary and gives me a validation warning in W3C validator (https://validator.w3.org). How can I do this? I have tried but not managed to accomplish this. I'm using the Html.RequiresJs in my razor view like this: @{Html.RequiresJs("/static/js/custom.js");}

Warning: The type attribute is unnecessary for JavaScript resources.

Best regards Kristian

Shazwazza commented 6 years ago

Hi, I think this is hard coded at the moment for all script tags, should be quite easy to add another config option to toggle this attribute. We can make it "opt-in" to maintain compatibility but all new installs of CDF would have this config option set to true so the attribute is not output, but upgrades would retain the attribute unless they add the config option.

I'll see what I can do, but if you want to give it a try and submit a PR that would be even better :)

ojemuyiwa commented 6 years ago

Excellent stuff @Shazwazza Could you please add similar functionality for "charset" attribute as w3c warns that both attributes are obsolete.

Kind regards

Shazwazza commented 6 years ago

CDF doesn't add any charset attribute to any html tags, so all good :)

ojemuyiwa commented 6 years ago

Oh my I'm (facepalm) so sorry I had too many git-hub tabs open. Sorry this is an angular cli question. Please Ignore.

Shazwazza commented 5 years ago

This is now merged in and fixed, there's a new config switch htmlCompatibility which by default is html4 for compatibility reasons, but can be changed to html5 to achieve this, see here for an example: https://github.com/Shazwazza/ClientDependency/blob/master/ClientDependency.Web.Test/Web.config#L29

StuartPaterson commented 5 years ago

I know this is a slightly older post but I'm on v7.10.5 and just trying to put this fix in place after basically copying and pasting from your example config file but my Umbraco instance isn't liking it.

error: Unrecognized attribute 'htmlCompatibility'. Note that attribute names are case-sensitive

I've updated the client dependency config file -

and updated the web.config with the new key - Is there anything else I'm missing? Thanks Stuart
Shazwazza commented 5 years ago

@StuartPaterson you'll need to update to use the latest CDF version, 7.10.x very likely ships with an older versin.