Is uppercase or lowercase javascript / html?

Is it better for compatibility / JIT performance compilation for using UPPER CASE or lowercase in JS / HTML? For instance,

<DIV> my content </DIV> <div> my content </div> ALERT(DOCUMENT.LOCATION); alert(document.location); 

This is not a newbie question; I know that lowercase is the de facto standard. But since I saw some uppercase JS + HTML, I was wondering what is better to write. (For example, is SQL completely capitalized?)

+4
source share
6 answers

I do not think that would change the speed.

XHTML: lowercase tags are what the W3C says.

JavaScript: maybe this will not work, because I have never seen any code use all caps in JS.

SQL is fully capitalized to distinguish actions, functions, etc. from actual data. You can use lowercase letters, but they become less readable (for some, including me).

IMO, sneaking through a bunch of uppercase tags, is less readable than lowercase tags. I would say that user agents do not care where the tags are. Here's a bit of history: when I created the site in 1999, uppercase tags were standard.

You can still find some dodgy non-updated websites that are still writing

'Use <B></B> to make the text bold'

+7
source

Wrong (in xhtml, at least) to use <DIV>...</DIV> ; this is <DIV>...</DIV> .

Similarly, I would use lower case in javascript (for alert(document.location); ), and their names ;-p

+2
source

I cannot imagine that this makes a difference in compatibility or performance. I think some people find UPPERCASE easier to recognize as markup or code rather than content.

You can do some tests if you need to.

(XHTML specifies lowercase letters as standard, so if your goal is validators, then go with that)

+1
source

JavaScript (using Fx3.0) is case sensitive.

 var myURL = document.URL; // sets myURL to the current URL var myURL2 = DOCUMENT.URL; // ReferenceError: "DOCUMENT" is not defined 

HTML allows the use of mixed type tags, XHTML requires only lowercase tags, attributes.

+1
source

This certainly matters with javascript, as it is case sensitive.

The accepted community standard for html is lowercase, although the browser does not care.

So be nice to those who should read your code later!

0
source

I would definitely go with lowercase letters where possible. I tend to resemble the variable names of several words of a camel, but even this can be discarded in favor of underlining.

0
source

All Articles