davidonet / Textopoly

Le Textopoly est un outil d’écriture en ligne, sur lequel chacun peut publier des textes et des images, en les agençant librement dans un espace virtuel infini. Ce paysage d’écriture est destiné à la création artistique et littéraire.
http://textopoly.bype.org
GNU General Public License v3.0
2 stars 2 forks source link

Transformer les classes uniques en ID #71

Closed davidonet closed 6 years ago

davidonet commented 11 years ago

As for which one to use, use whichever is most appropriate. If you have a search box on your page then using an ID for that would be most appropriate because there's only one search box. Table rows on the other hand will probably be identified by class because there is (or can be) more than one.

Try not to use selectors (in CSS or jQuery) like ".class". You're forcing jQuery or the browser to basically traverse the entire document tree. Most of the time the class will only apply to one kind of tag so specify that (eg "div.class"). That alone can make a huge performance difference (particularly on jQuery with a large document).

The length of the selector should not be a consideration. Performance, readability and maintainability should be.