简体   繁体   中英

What is the proper way to format a JavaScript tag?

Having developed web apps since 1996 I often find new ways of doing old things. So I was wondering what is the proper JavaScript tag to use on new development?

Currently I use something like this for XHTML

<script type="text/javascript">
/* <![CDATA[ */

/* ]]> */
</script> 

I have read somewhere that this may cause problem with older browsers.

But use to use the following:

<script language="javascript">

<script type="text/javascript">

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

What is the prefered method and why?

Checkout what Crockford has to say. In summary:

<script src="url"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM