Apprendre jQuery, bonnes pratiques
- Official jQuery Learning Center
- jQuery Coding Standards & Best Practices – These are some of the common standards and best practices for writing better code with jQuery.
- JQUERY BEST PRACTICES by Greg Franko
- 10 Ways to Instantly Increase Your jQuery Performance
- jsperf.com – jsPerf aims to provide an easy way to create and share test cases, comparing the performance of different JavaScript snippets by running benchmarks.
jQuery Performance Rules
- Always Descend From an #id
- Use Tags Before Classes
- Cache jQuery Objects
- Harness the Power of Chaining
- Use Sub-queries
- Limit Direct DOM Manipulation
- Leverage Event Delegation (a.k.a. Bubbling)
- Eliminate Query Waste
- Defer to $(window).load
- Compress Your JS
- Learn the Library
- Avoid use of string concat(), Use join() for the long strings.
- Use Latest jQuery versions with CDN hosted files instead of older version.
- Use of For loop instead of jQuery $.each loop.
- Check if an Element Exists before doing operations on the DOM elements.
- Always use Return False in functions.
- Use of HTML5 Data Attributes.
- Identify weight of the page.
- Keep your code DRY (Don’t Repeat Yourself)
Boilerplates, starter kits
- jQuery Boilerplate – Jump-starting jQuery plugins development. The following guide, adapted from jQuery Plugins/Authoring, will outline the basics, best practices, and common pitfalls to watch out for as you begin writing your plugin. Example sous JSBin pour manipuler en live.
- Handling plugin defaults and predefinitions où comment donner la possibilité à l’utilisateur de son plug-in de modifier des options à la volée.
Autre (n’a peut-être pas sa place dans ce billet…)
- Using jQuery .on() and .off() – Andi Smith