📜 ⬆️ ⬇️

Sampling rate of CSS selectors in JavaScript libraries

Along with comparative tests of the load time of various JavaScript libraries, it was interesting to see how the most popular actions are optimized in them, namely the selection of elements by CSS selectors. Indeed, even in the simplest JavaScript code based on such libraries, several dozens of such operations are used, not to mention complex interfaces and full-fledged web applications.

Let me give you a typical example of jQuery code that uses the CSS selector engine:

  $ (function () {
     $ ("a.clip"). click (function () {
         $ ("# clip" + $ (this) .attr ("rel")). slideToggle (500);
         if ($ (this) .html () == "+") {
     $ (this) .html ("& ndash;");
         } else {
     $ (this) .html ("+");
         }
         return false;
     });
 }) 

')
read further on webo.in →

Source: https://habr.com/ru/post/24737/


All Articles