getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.5k stars 1.4k forks source link

Drop "type" attribute for JavaScript in HTML5 #1837

Open r2d02 opened 6 years ago

r2d02 commented 6 years ago

In HTML5 the attribute type="text/javascript" is no longer needed/optional (it was needed until version 5 of HTML). I believe this level of verbosity is not needed and thus should be dropped.

FWIW it also gives a warning in the W3 validator

https://www.w3.org/TR/html5/document-metadata.html#processing-link-type

mahagr commented 6 years ago

Yes, default type can be dropped -- though we need still to support type="application/json" and other types. Same is true with css, too.

pgr1973 commented 6 years ago

You can bodge it away with something like this in the twig-file(s):

{{ assets.css()|replace({ 'type="text/css" ': ''}) }}

{{ assets.js()|replace({ 'type="text/javascript" ': ''}) }}

{{ assets.js('bottom')|replace({ 'type="text/javascript" ': ''}) }}

For instance in the /[THEME]/templates/partials/base.html.twig