#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171

    Javascript element with or without attributes?


    Hello;

    Whichone is the correct way of using Javascript element?
    Code:
    <script src="s.js" type="application/javascript" language="javascript"></script>
    <script src="s.js" language="javascript"></script>
    <script src="s.js" type="application/javascript"></script>
    <script src="s.js"></script>
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    The language attribute is deprecated, but having it doesn't break anything.

    As of HTML5, the type attribute is optional. Even before HTML5, the script tag will still work without it.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4304
    Good question.

    IE8 and older don't seem to recognize
    Code:
    <script src="s.js" type="application/javascript"></script>
    This is what I recommend and use myself:
    Code:
    <script src="s.js" type="text/javascript"></script>
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo