jQuery Standards and Best Practice [closed]
Solution 1:
You can find this trending topic right here in StackOverflow.com
jQuery pitfalls to avoid
Very interesting useful tips one after the other.
here are some more i found in my bookmarks:
- http://paulirish.com/2011/11-more-things-i-learned-from-the-jquery-source/
http://jquery.open2space.com/http://thetoptenme.wordpress.com/2008/08/19/the-complete-guide-for-jquery-developer-reblog/http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx
Solution 2:
Something I've personally started to do is a sort of an Apps Hungarian Notation for jQuery sets, by prefixing those variables with a $
var someInt = 1;
var $someQueryCollection = $( 'selector' );
I find that as my jQuery snippets grow, this becomes invaluable, not only in the promotion of storing jQuery sets as variables, but to help me keep track of which variables actually are jQuery sets.
Solution 3:
Unobtrusive JavaScript (separation of markup and behavior)
Back in the days, it was common to put your click handler inside the markup. Now it's recommended that you do not write your JS code inside your markup but include it via DOM events.
Progressive enhancement
User gets better experience if they are using standards compliant browser and/or has JavaScript enabled. Website/web application is still accessible even if they have older browser or has JS disabled.
Feature detection and not browser detection
Keeping above points aside, I would really focus on conveying the message (breaking the pre-conceived notion) that JavaScript is a toy language. I have seen too many developers who thinks this way and everything is downhill from there. You need to explain them how JavaScript is a very powerful language and why they need a JS library (because of browser inconsistencies) even though JS itself is very powerful.
Good luck.