Editing id vs class vs tag vs pseudo vs. attribute selectors This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Comparing the performance difference of varied jQuery 1.7 selectors. This test page contains some dummy HTML (from html-ipsum.com) just to give the page some weight, make the selectors work a little bit. Note that the "Tag" selector is selecting a tag that happens to be unique in the page just to be fair. Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <style type="text/css"> .bar { display: none; } </style> <h1> HTML Ipsum Presents </h1> <div id="theDiv"> <div> <p> <strong> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, </strong> <code> commodo <em> Aenean ultricies mi vitae est. </em> vitae </code> , ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis. </p> </div> </div> <h2> Header Level 2 </h2> <ol> <li> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </li> <li> Aliquam tincidunt mauris eu risus. </li> </ol> <blockquote id="foo" class="bar" name="baz"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est. </p> </blockquote> <h3> Header Level 3 </h3> <ul> <li> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </li> <li> Aliquam tincidunt mauris eu risus. </li> </ul> <pre> <code> #header h1 a { display: block; width: 300px; height: 80px; } </code> </pre> <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code $("#theDiv div p code em"); Test 2 Title Async (check if this is an asynchronous test) Code $("#theDiv > div:first-child > p > code > em"); Test 3 Title Async (check if this is an asynchronous test) Code $("#theDiv em"); Test 4 Title Async (check if this is an asynchronous test) Code $("#theDiv"); Test 5 Title Async (check if this is an asynchronous test) Code $("em");