?
avatar Chaosxmk
Chaosxmk
7 Sep 2018

Is your feature request related to a problem? Please describe.

According to current specification for HTML 5 compliant browsers, the type attribute of script tags isn't required if the type is JavaScript. Modern browsers automatically identify omitted script types as JavaScript. No matter what value is sent as type attribute, type will be added, even sending an empty string.

JFactory::getDocument()->addScript('script.js', array(), array('type' => ''));
Becomes:
<script src="script.js" type=""></script>

Describe the solution you'd like

To avoid setting off any deprecated behavior (but also not break backwards compatibility), why not have it set so that if a user provides an empty string for type, the type attribute isn't set.

JFactory::getDocument()->addScript('script.js', array(), array('type' => ''));
Becomes:
<script src="script.js"></script>

avatar Chaosxmk Chaosxmk - open - 7 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - change - 7 Sep 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Sep 2018
avatar mbabker
mbabker - comment - 7 Sep 2018

You should still pass the type forward when registering scripts.

The HtmlDocument class has a parameter to toggle whether the document is built as HTML5 or HTML4/XHTML (it defaults to HTML4/XHTML in 3.x and in 4.0 defaults to HTML5), and the script rendering process already omits the type attribute in this case.

So best practice should be to always pass the type. If you're building a template and want it to output as a HTML5 document, call $this->setHtml5(true); in your template's index.php file and core will take care of altering the output as appropriate.

avatar Chaosxmk
Chaosxmk - comment - 7 Sep 2018

Honestly, I feel like somewhere along the line, I just failed to read/understand the documentation for templates and missed that line entirely. Thank you for pointing it out.

avatar joomla-cms-bot joomla-cms-bot - change - 7 Sep 2018
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 7 Sep 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Sep 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-09-07 15:25:04
Closed_By franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 7 Sep 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Sep 2018

closed as Issue looking solved. If i'm wrong please pardon and reopen.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22039.

Add a Comment

Login with GitHub to post a comment