Tuesday, March 11, 2014

jQuery Coding Standards and Best Practices

I’ve been using jQuery for the past couple of years and have seen a lot of bad practices and lack of standards knowledge between the developers. It’s always better to have standards defined around big teams so everyone’s on the same page. I took this effort to unify the coding standards and best practices around jQuery under one page so others can build upon it. Not all standards may apply to your application so feel free to use whatever works best for your application domain.

http://lab.abhinayrathore.com/jquery-standards/

If you find any mistakes, have any suggestions or comments, please feel free to drop a word below this post and I’ll try to address it as soon as possible.

13 comments:

  1. Have you considered a wiki page on GitHub? That would make it easier to report issues or suggest improvements.

    ReplyDelete
  2. I stopped at "use IDs whenever possible". I strongly disagree, I hope to have time one day to write why.

    ReplyDelete
    Replies
    1. Now i'm curious why do you desagree in using IDs whenever possible... i see the point in the post (which is really usefull) and i kinda agree with him... I'd love to know what is your argument for your opinion.

      Delete
    2. we want to know!!

      Delete
    3. Yeah! Been there, done that with ID's.....Your post is really kind man!

      Delete
  3. Are you kidding me?
    When using class/pseudo selectors, always use the element type in your selector to avoid scanning of all DOM elements.
    http://jsperf.com/jqeury-selector-test

    ReplyDelete
    Replies
    1. Thanks for this find. I'll update the page :)

      Delete
  4. Very useful recommendations. The only exception for me was the "Avoid Excessive Specificity". For me, using Chrome 33.0.1750.152 on Linux 64-bit, the more you specify your selector the fastest it'll be. Although the performance gain it not that significant.

    Thanks!

    ReplyDelete
  5. I found a lot of information here to create this actually best for all newbie here. Thank you for this information.
    Signature:
    facebook entrar iniciar sesion gratis - Sitio Oficial iniciado sesión en Facebook lengua española. facebook entrar rápido, facebook iniciar sesion en tu cuenta de entrar facebook

    ReplyDelete
  6. One of the links you mention (http://www.paulirish.com/2010/the-protocol-relative-url/) has actually been updated to say the opposite: "Now that SSL is encouraged for everyone and doesn’t have performance concerns, this technique is now an anti-pattern. If the asset you need is available on SSL, then always use the https:// asset."

    ReplyDelete
  7. Thanks for posting! Very useful.

    ReplyDelete
  8. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic.


    Pawn Shop

    Pawn Loans

    Pawn Shops

    Pawn Loan

    Pawn Shop near me

    ReplyDelete

Thanks a lot for your valuable comments :)