WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 weeks ago

#18788 reopened enhancement

Remove redundant type attributes from script and style tags

Reported by: solarissmoke Owned by:
Milestone: 4.2 Priority: normal
Severity: normal Version: 3.3
Component: Script Loader Keywords: 3.4-early has-patch
Focuses: administration Cc:

Description

Now that the admin is using the HTML5 doctype everywhere, the type="text/javascript" and type="text/css" attributes on script and style tags are unnecessary (if they weren't anyway), and I think they can be safely removed to trim a few hundred bytes from core. Should be a simple search and replace exercise.

Attachments (2)

no-cdata.diff (10.2 KB) - added by tw2113 3 years ago.
removed script CDATA tags. Left script types on though.
no-cdata1.diff (12.2 KB) - added by tw2113 3 years ago.
forgot wp-includes

Download all attachments as: .zip

Change History (18)

comment:1 @azaozz3 years ago

  • Keywords 3.4 added
  • Milestone changed from Awaiting Review to Future Release

We have to confirm that first for older mobile browsers. They still might be needed for some. Also the //<![CDATA[ bits inside of <script> are not needed.

comment:2 @tw21133 years ago

  • Cc michael.d.beckwith@… added

@tw21133 years ago

removed script CDATA tags. Left script types on though.

@tw21133 years ago

forgot wp-includes

comment:3 @tw21133 years ago

  • Keywords has-patch added

I did my best to stick to just <script></script> blocks. I didn't edit any of them in RSS/XML based feed files.

comment:4 @retlehs2 years ago

  • Cc retlehs added

comment:5 @Volker_E.2 years ago

  • Cc Volker_E. added

comment:6 @SergeyBiryukov23 months ago

  • Keywords 3.4 removed

HTML comment tags in wp-admin/includes/file.php can also be removed:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/includes/file.php#L969

comment:7 @SergeyBiryukov23 months ago

  • Keywords 3.4-early added

Fixing the keyword for reference.

comment:9 @nacin13 months ago

  • Component changed from Administration to Script Loader
  • Focuses administration added

comment:10 @wonderboymusic2 months ago

  • Milestone changed from Future Release to 4.2

comment:11 @wonderboymusic2 months ago

In 31034:

Inline <script>s that are only printed in the admin for pages that are served with the HTML5 doctype absolutely do not need CDATA comments.

Props tw2113 for the initial patch.
See #18788.

comment:12 follow-up: @wonderboymusic2 months ago

  • Resolution set to fixed
  • Status changed from new to closed

type is optional in HTML5, not required. I don't think it hurts to keep it.

comment:13 in reply to: ↑ 12 ; follow-up: @retlehs2 months ago

Replying to wonderboymusic:

type is optional in HTML5, not required. I don't think it hurts to keep it.

Since it's optional, why keep it?

comment:14 in reply to: ↑ 13 ; follow-up: @AramZS6 weeks ago

Replying to retlehs:

Replying to wonderboymusic:

type is optional in HTML5, not required. I don't think it hurts to keep it.

Since it's optional, why keep it?

Always better to be more specific than less, right?

comment:15 in reply to: ↑ 14 @solarissmoke6 weeks ago

Replying to AramZS:

Always better to be more specific than less, right?

The HTML5 specification is explicitly clear about what a missing type attribute means, so specificity isn't an issue. Removing it means less bloat and easier code to read.

comment:16 @retlehs3 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening because type still isn't removed.

Note: See TracTickets for help on using tickets.