I think I’m a bit out of the loop on the proper way to form codie for js scripts, and thoughts seem to differ when speaking to others about it. I had this code 10 years ago, but is it still okay please?
The type=“text/javascript” attribute/value was required for validation prior to html5 but has always been unnecessary as browsers know exactly what to do with a script. These days you should omit it and save on code.
as long as the server is set to use application/javascript for scripts.
Note that text/javascript was deprecated a long time ago - the only reason people continued using it was that before IE9 Internet Explorer didn’t run JavaScript but ran jScript instead which would run with text/javascript as the MIME type but not the correct JavaScript one.
I still include the type=“application/javascript” when using script tags as I suspect that the shared hosting I am using has the wrong type set.
This attribute is optional. Since Netscape 2, the default programming language in all browsers has been JavaScript. In XHTML, this attribute is required and unnecessary. In HTML, it is better to leave it out. The browser knows what to do.
I can’t say I’ve ever done it myself either. It was more a case of pointing out what MDN says browser should assume if that attribute is left out - the implication being that it can be done.
The official recommendations can be found at http://tools.ietf.org/html/rfc4329 and specify application/javascript and application/ecmascript as the only two valid alternatives - all the others are labelled as obsolete and problematic.