Blog

The type attribute is unnecessary for JavaScript resources...
How to fix this warning on Joomla 3.X Template by HTML errors checking tool.

All Templates developers like to see their works error free, me too.

Since few weeks seems that the W3C HTML Checker finds a new Warning if your Template is not correctly set to HTML 5 output.
If the HTML Checker shows something like that:

Warning: The type attribute is unnecessary for JavaScript resources.

it can be that your Template has no DOCtype declaration (I don't mean the TAG <!doctype html>) and it is not correctly rendered.

What you have to do is set a variable to "true" in JFactory class.

In the upper section of your Template (in the PHP area) write this code:

// Set HTML5 Document Output
$docHTML = JFactory::getDocument();
$docHTML->setHtml5(true);

upload and press Refresh (F5), all script declarations become FROM:

<script> src="/media/jui/js/jquery.min.js?..." type="text/javascript"></script>
<script> src="/media/jui/js/jquery-noconflict.js?..." type="text/javascript"></script>
<script> src="/media/jui/js/jquery-migrate.min.js?..." type="text/javascript"></script>
...

TO:

<script> src="/media/jui/js/jquery.min.js?..."></script>
<script> src="/media/jui/js/jquery-noconflict.js?..."></script>
<script> src="/media/jui/js/jquery-migrate.min.js?..."></script>
...

If you wrote some custom script or CSS in your Template you have to correct this manually !!!

The setting HTML5 = true works only in Joomla Head Renderer and not on your custom code.
If you wrote something like this:

<link href=" <?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/general.css" rel="stylesheet" type="text/css" />

or like this:

<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/jquery-1.8.3.min.js"> </script>

you have to correct this manually.

Thanks, Fabrizio.

 
 
 
  • |
  • |
  • Modified: 08 / 01 / 2018