I’m trying to get a start here on Codecanyon and I want to know if there are any coding guidelines that I should follow for JavaScript files (or any other file). I’m especially curious if I should follow a specific commenting convention for classes?
Thank you,
Alex
Just follow good, industry standard practices and you’ll be fine. Comments are secondary and usually not a factor if an item is accepted or rejected.
jwmcpeak said
Just follow good, industry standard practices and you’ll be fine. Comments are secondary and usually not a factor if an item is accepted or rejected.
Thanks for the info. Cheers
As you probably already know some of this, it might not help; but it’s the same principle for anything code-based written.
Simple School Boy Guidelines:
1.Keep your code clean and cluster free.
2. Use shorthand code instead of writing everything our separately; use wherever possible.
For example:
$(function(){
$('#div').on('click', function() {
$('#div').css('background-image', 'url(img/folder/file.png)');
$('.div2').css('color', '#fff');
$('.div3').css('color', '#fff');
$('.div4').css('color', '#fff');
})
});
Would become:
$(function(){
$('#div').on('click', function() {
$('#div').css('background-image', 'url(img/folder/file.png)');
$('.div2, .div3, .div4').css('color', '#fff');
})
});
I could go on and on and on, about using (this) and (that) forever, but here is a great practice site here:
http://www.jameswiseman.com/blog/2010/04/20/jquery-standards-and-best-practice/
It’s got practically everything you need.
JMDDesigns said
As you probably already know some of this, it might not help; but it’s the same principle for anything code-based written
.... I could go on and on and on, about using (this) and (that) forever, but here is a great practice site here:
http://www.jameswiseman.com/blog/2010/04/20/jquery-standards-and-best-practice/
It’s got practically everything you need.
Every infromation is usefull. Although there are tons of resources out thereI thought maybe here on codecanyon there are some specific guidelines/rules to follow.
Thanks for your reply.
For Javascript, jslint (http://www.jslint.com/) can help a lot in keeping your code consistent, and even catching some bugs along the way.
pjtops said
For Javascript, jslint (http://www.jslint.com/) can help a lot in keeping your code consistent, and even catching some bugs along the way.
Great. Thanks for sharing! 
- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
I prefer http://www.jshint.com/
I also hate using anonymous functions and coming from AS3 you probably will too 
Good luck 
CodingJack said
I prefer http://www.jshint.com/I also hate using anonymous functions and coming from AS3 you probably will too
Good luck![]()
Yup… It’s a pain. But what can you do? Need to move on with industry standards (?).
Also, thank you!
JMDDesigns said
Would become:
$(function(){ $('#div').on('click', function() { $('#div').css('background-image', 'url(img/folder/file.png)'); $('.div2, .div3, .div4').css('color', '#fff'); }) });
Do you really use the jquery css method to set a background image and to change colors?
