Is type="text/javascript" necessary?

Example:
<script type="text/javascript" src="https://www.youtube.com/player_api"></script>

Some people add it, some people don’t.

It depends. What DOCTYPE does the page have?

1 Like

Worth reading - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

1 Like
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
  <b:if cond='data:blog.isMobile'>
    <meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
    <b:else/>
    <meta content='width=1100' name='viewport'/>
  </b:if>
  <b:include data='blog' name='all-head-content'/>
  <title><data:blog.pageTitle/></title>
 
 <b:skin><![CDATA[

Hi there asasass

what is your reasoning for using this…

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>

Whatever it is, you should be aware
that it causes a validation error…

Error : Saw <? . Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.) [At line 1, column 2](https://validator.w3.org/nu/#cl1c2) ```<?xml version="1.0" encoding="UTF-8" ?>```

coothead

What does the Doctype read here?
https://blankbloggerattempt.blogspot.com/

Here is the result of the reading

14 errors and 7 warnings

…click the link for the actual details. :winky:

p.s. the document does not include…

<?xml version="1.0" encoding="UTF-8" ?>

coothead

Can you tell me how many errors this one has?
https://www.blog.google/

Nope. I’m on an iPad

Hi there asaasass,

it has a total of 74 errors and warnings

blog.google*validation results

coothead

Hi there asaasass,

to validate pages yourself just bookmark this link…

https://validator.w3.org/

…and pop the page location in the address bar. :winky:

It might supply hours of fun for you on a dull day. :biggrin:

coothead

5 Likes

Having 14 errors isn’t so bad then.

I’m better than Google.

[off topic]
I’m a great believer in validation for two main reasons.

Firstly, validated web pages have a far greater chance of rendering virtually the same on all web browsers. If the extra step of using Google Mobile Friendly validation then rendered output should be ok on all platforms.

Secondly, trying to render invalid web pages puts additional strain on web browsers because they have to guess what is trying to be achieved - this takes time and will result in web pages being slow to load.

[/off topic]

2 Likes

DuckDuckGo

…might also be better than Google. :rofl:

coothead

2 Likes

That strikes me as rather like saying “I’m not so bad - I’ve only got two broken legs. That guy over there has four broken bones and a dislocated shoulder.”

Just because Google (or any other big site) uses invalid code is no reason to be complacent about having invalid code yourself.

1 Like

google may have errors that don’t effect anything much, your site may have errors that cause complete failure under certain circumstances. I was reading about the perils of putting certain things into the head section that then cause some search engines to ignore the head as it doesn’t know what it should be trusting. So you could lose any hard work you’ve done on ensuring you have good description tags etc in an instant.

Additionally if you are a mutli-billion dollar company that most of the world use to search the internet you can probably get away with some errors. If you have a small site that you are trying to get people to come to (and hopefully return to) seems to me like having it valid is just another thing you don’t have to worry about and you can concentrate on other factors.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.