Remove unnecessary in HTML 5 type attribute with default value #5748

Merged
merged 1 commit into from Apr 8, 2012

Conversation

Projects
None yet
6 participants
Contributor

ai commented Apr 5, 2012

In HTML 5 type attribute in <style>, <script> and <link rel="stylesheet"> have default value (text/javascript or text/css), so it’s unnecessary now.

By default, app/views/layout/application.html.erb have HTML 5 doctype, so we can miss type attribute.

Without it code will become cleaner and shorter.

If someone use HTML 4, browser will understand tags without type. Also HTML 4 users can just set type by :type params in javascript_include_tag, etc.

Contributor

ai commented Apr 5, 2012

Member

josevalim commented Apr 5, 2012

Before merging this, I think it is worth to have a break down of which browsers this would work and their market share. Since the gain here is merely aesthetic, I don't think it is enough to break compatibility unless 99% of the browsers can handle this fine.

Contributor

ai commented Apr 5, 2012

All old browsers correctly support <script>, <style>, <link rel="stylesheet"> wuthout type. In HTML 4 we need to add type only to validation.

Owner

jeremy commented Apr 5, 2012

Good eye, @ai. 👍 to merge. No reason to explicitly state the default types.

Contributor

ai commented Apr 8, 2012

@josevalim HTML5 Doctor say, that type attr is common HTML5 mistake. Also HTML5 boilerplate also use <script> and <link> without type. Of cource, thay willn’t do this, if this broke backwards compatibility.

@jeremy jeremy added a commit that referenced this pull request Apr 8, 2012

@jeremy jeremy Merge pull request #5748 from ai/no_type_in_html5
Remove unnecessary in HTML 5 type attribute with default value
0032da1

@jeremy jeremy merged commit 0032da1 into rails:master Apr 8, 2012

@ai why the type attribute is still generated when I use javascript_include_tag method? (Rails 3.2.9)

Contributor

ai commented Dec 23, 2012

@nightire because, as I understand, this fix go to Rails 4 :(.

Owner

pixeltrix commented Dec 23, 2012

@nightire as @ai correctly points out the change is on master only and a backport isn't appropriate because it would change the output of existing apps which we don't do in point releases unless we have to due to bugs, regressions or security fixes.

@pixeltrix @ai ok, thanks both of you. I try to use javascript_include_tag "application", type:nil instead, it works good for now.

Contributor

NARKOZ commented Dec 28, 2012

What about trailing slashes (xhtml style) in tags? They're not necessary in html5.

Owner

pixeltrix commented Dec 28, 2012

@NARKOZ if you search here and on the mailing list a bit you can see we've had that discussion before so I'd appreciate it if we don't go over it again - the trailing slashes are perfectly acceptable in HTML5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment