(1)
Non-externalized, non-minified, non-compressed scripts should be avoided.
For minification, I have YUICompressor aliased
alias compress="java -jar /usr/local/src/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar"
#usage is simply
compress file.(js|cs) -o file.min.(js|cs)
And there are probably many static file servers with options to gzip or deflate.
My static file handler (mod) does this, but the version you'll find on npm is not great.
I have a much better version on my personal machine but I've removed many options because, for example, every browser ever supports gzip so we'd like to send that to clients without option & cache it as-is instead of recompressing for every new client. Anyway, you could clone that repository and improve it if you like. That way you know what's happening.
(2)
Inline CSS should be avoided
(3)
The slowest way to select an element is by class, so naturally this should be avoided if possible in both jQuery and CSS selectors. Also, ID selectors are for individual elements. So they are perfectly fine to select individual elements on their own. Consider the following from index.ejs
This is not only redundant, as there is only one element with a classname of "container," and only one element with an ID of "body," it is one of the worst individual selectors you can possibly create. More than that, both the classname and ID is hardly descriptive!
Something like this would be much better but still not exactly useful.
(4)
For canceling the default behavior of events, use something like this
$('form').submit(function(e) {
e.preventDefault()
e.stopPropagation()
})
Instead of returning false
(1)
Non-externalized, non-minified, non-compressed scripts should be avoided.
For minification, I have YUICompressor aliased
And there are probably many static file servers with options to gzip or deflate.
My static file handler (mod) does this, but the version you'll find on npm is not great.
I have a much better version on my personal machine but I've removed many options because, for example, every browser ever supports gzip so we'd like to send that to clients without option & cache it as-is instead of recompressing for every new client. Anyway, you could clone that repository and improve it if you like. That way you know what's happening.
(2)
Inline CSS should be avoided
(3)
The slowest way to select an element is by class, so naturally this should be avoided if possible in both jQuery and CSS selectors. Also, ID selectors are for individual elements. So they are perfectly fine to select individual elements on their own. Consider the following from index.ejs
This is not only redundant, as there is only one element with a classname of "container," and only one element with an ID of "body," it is one of the worst individual selectors you can possibly create. More than that, both the classname and ID is hardly descriptive!
Something like this would be much better but still not exactly useful.
(4)
For canceling the default behavior of events, use something like this
Instead of returning false