Rules to Better JavaScript and jQuery

Optimize your JavaScript and jQuery practices with essential guidelines that enhance code quality and maintainability. This collection covers best practices for coding standards, library usage, and effective debugging, ensuring that your scripts run efficiently and reliably across different environments.

  1. For most of the cases, it quite rare to have problems when omitting semicolons, but there are a few scenarios where they are required to prevent syntax errors or resolve code ambiguities.

  2. We all know that jQuery is very powerful and can do a lot of stuff, including style changes. However, this practice is bad.

  3. Don't assume JavaScript is always enabled.

    JavaScript should be used to enhance the overall user experience and not as a dependency.

  4. $(#id) is a selector of jQuery. It gets the single element with the given id.

    jQuery is a fast and concise JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.

  5. Comments are used to add extra information pertaining to your code. They not only make you understand your code when you look at it after a period of time, but it also help other people who might be working with you on the same project.

  6. The Javascript command "eval" evaluates the content of a text string and then runs it as Javascript code. It's common to see it around, however "eval" is one of the most inefficient constructs that JavaScript has. There are always more efficient ways to code and get a direct reference.

  7. Below are some of the best technically cool jQuery plug-ins. Use these as guidelines for building your jQuery plug-ins:

  8. Below are some of the best visually cool jQuery plug-ins. Use these as guidelines for building your jQuery plug-ins:

  9. TypeScript is the new flagship language from Microsoft that compiles into JavasScript.

    • Use JavaScript if you’re writing page specific script
    • Use jQuery to improve cross-browser support
    • Use TypeScript if you’re writing re-usable client side library

    Don't use CoffeeScript (language is too different from JavaSript)

  10. The popup blockers in several browsers prevent JavaScript from being used to open windows without user interaction (e.g. clicking a link). You should use an anchor tag instead.

per page
1 - 10 of 25 items
We open source.Loving SSW Rules? Star us on GitHub. Star