
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
37 lines
1.0 KiB
Plaintext
37 lines
1.0 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Even if your document is arranged in many layers, you don't have to step through those layers explicitly to select an element. In fact, it's more efficiently to skim over some of those layers rather than making the JQuery selector engine explicitly step through each one.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
$( "div.data table.attendees td.campbell" ); // Noncompliant; too many selectors. There's no need to trace through each layer of the structure
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
$( ".data td.campbell");
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 6 May 2015, 09:57:44 Elena Vilchik wrote:
|
|
Performance tests show that long selector might be significantly faster than the shorter one (as in code examples).
|
|
|
|
http://jsperf.com/complex-selectors-sq
|
|
|
|
Screenshot of pert test results is attached.
|
|
|
|
So recommendations of this rule could affect code performance in a bad way.
|
|
|
|
endif::env-github,rspecator-view[]
|