WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#24796 closed defect (bug) (invalid)

wp_enqueue_script causing HTML5 Validation Error

Reported by: tislam100 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.2
Component: General Keywords:
Focuses: Cc:

Description

Some plugins are using wp_enqueue_script to display inline javascript without src. the output of those scripts should be like this:

<script type="text/javascript">
custom javascript
</script>

but it adds the extra charset="utf-8" attribute which is not valid in html5 without a src.

<script type="text/javascript" charset="utf-8">
custom javascript
</script>

wp_enqueue_script should check whether the called script has a src, if not, then dont add the charset attribute. Imo this should be treated seriously as most of the themes are now html5. and the html5 validity status of this issue is "Error", not a "Notice".

Thanks

Change History (7)

#1 follow-up: @nacin
8 years ago

I'm not aware of the scripts API supporting or using the charset attribute, or even supporting inline JavaScript in such a way.

#2 @SergeyBiryukov
8 years ago

wp_enqueue_script should check whether the called script has a src

Related: #22470

#3 @tislam100
8 years ago

Sorry guys. should have searched before.
Is this going to be fixed in the next version?

Thanks

#4 in reply to: ↑ 1 @nacin
8 years ago

Per my comment above:

Replying to nacin:

I'm not aware of the scripts API supporting or using the charset attribute, or even supporting inline JavaScript in such a way.

I don't see how this is a bug in core. We don't go near the charset attribute when printing <script> tags.

#5 @tislam100
8 years ago

yes Nacin you are correct. As i looked into the class.wp-scripts.php looks like wordpress doesn't.

Looks like its caused by a plugin.

you guys can discard this ticket as its invalid.

Sorry.

#6 @SergeyBiryukov
8 years ago

  • Component changed from Charset to General
  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

#7 @nacin
8 years ago

No problem, thanks for the report!

Note: See TracTickets for help on using tickets.