get id

JavaScript performance comparison

Revision 2 of this test case created by LesTR

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"></script>
<a href="#" id="0">Link 0</a>
<a href="#" id="1">Link 1</a>
<a href="#" id="2">Link 2</a>
<a href="#" id="3">Link 3</a>
<a href="#" id="4">Link 4</a>
<a href="#" id="5">Link 5</a>
<a href="#" id="6">Link 6</a>
<a href="#" id="7">Link 7</a>
<a href="#" id="8">Link 8</a>
<a href="#" id="9">Link 9</a>
<a href="#" id="10">Link 10</a>
<a href="#" id="11">Link 11</a>
<a href="#" id="12">Link 12</a>
<a href="#" id="13">Link 13</a>
<a href="#" id="14">Link 14</a>
<a href="#" id="15">Link 15</a>
<a href="#" id="16">Link 16</a>
<a href="#" id="17">Link 17</a>
<a href="#" id="18">Link 18</a>
<a href="#" id="19">Link 19</a>
<a href="#" id="20">Link 20</a>
<a href="#" id="21">Link 21</a>
<a href="#" id="22">Link 22</a>
<a href="#" id="23">Link 23</a>
<a href="#" id="24">Link 24</a>
<a href="#" id="25">Link 25</a>
<a href="#" id="26">Link 26</a>
<a href="#" id="27">Link 27</a>
<a href="#" id="28">Link 28</a>
<a href="#" id="29">Link 29</a>
<a href="#" id="30">Link 30</a>
<a href="#" id="31">Link 31</a>
<a href="#" id="32">Link 32</a>
<a href="#" id="33">Link 33</a>
<a href="#" id="34">Link 34</a>
<a href="#" id="35">Link 35</a>
<a href="#" id="36">Link 36</a>
<a href="#" id="37">Link 37</a>
<a href="#" id="38">Link 38</a>
<a href="#" id="39">Link 39</a>
<a href="#" id="40">Link 40</a>
<a href="#" id="41">Link 41</a>
<a href="#" id="42">Link 42</a>
<a href="#" id="43">Link 43</a>
<a href="#" id="44">Link 44</a>
<a href="#" id="45">Link 45</a>
<a href="#" id="46">Link 46</a>
<a href="#" id="47">Link 47</a>
<a href="#" id="48">Link 48</a>
<a href="#" id="49">Link 49</a>
<a href="#" id="50">Link 50</a>
<a href="#" id="51">Link 51</a>
<a href="#" id="52">Link 52</a>
<a href="#" id="53">Link 53</a>
<a href="#" id="54">Link 54</a>
<a href="#" id="55">Link 55</a>
<a href="#" id="56">Link 56</a>
<a href="#" id="57">Link 57</a>
<a href="#" id="58">Link 58</a>
<a href="#" id="59">Link 59</a>
<a href="#" id="60">Link 60</a>
<a href="#" id="61">Link 61</a>
<a href="#" id="62">Link 62</a>
<a href="#" id="63">Link 63</a>
<a href="#" id="64">Link 64</a>
<a href="#" id="65">Link 65</a>
<a href="#" id="66">Link 66</a>
<a href="#" id="67">Link 67</a>
<a href="#" id="68">Link 68</a>
<a href="#" id="69">Link 69</a>
<a href="#" id="70">Link 70</a>
<a href="#" id="71">Link 71</a>
<a href="#" id="72">Link 72</a>
<a href="#" id="73">Link 73</a>
<a href="#" id="74">Link 74</a>
<a href="#" id="75">Link 75</a>
<a href="#" id="76">Link 76</a>
<a href="#" id="77">Link 77</a>
<a href="#" id="78">Link 78</a>
<a href="#" id="79">Link 79</a>
<a href="#" id="80">Link 80</a>
<a href="#" id="81">Link 81</a>
<a href="#" id="82">Link 82</a>
<a href="#" id="83">Link 83</a>
<a href="#" id="84">Link 84</a>
<a href="#" id="85">Link 85</a>
<a href="#" id="86">Link 86</a>
<a href="#" id="87">Link 87</a>
<a href="#" id="88">Link 88</a>
<a href="#" id="89">Link 89</a>
<a href="#" id="90">Link 90</a>
<a href="#" id="91">Link 91</a>
<a href="#" id="92">Link 92</a>
<a href="#" id="93">Link 93</a>
<a href="#" id="94">Link 94</a>
<a href="#" id="95">Link 95</a>
<a href="#" id="96">Link 96</a>
<a href="#" id="97">Link 97</a>
<a href="#" id="98">Link 98</a>
<a href="#" id="99">Link 99</a>
<a href="#" id="100">Link 100</a>
<a href="#" id="101">Link 101</a>
<a href="#" id="102">Link 102</a>
<a href="#" id="103">Link 103</a>
<a href="#" id="104">Link 104</a>
<a href="#" id="105">Link 105</a>
<a href="#" id="106">Link 106</a>
<a href="#" id="107">Link 107</a>
<a href="#" id="108">Link 108</a>
<a href="#" id="109">Link 109</a>
<a href="#" id="110">Link 110</a>
<a href="#" id="111">Link 111</a>
<a href="#" id="112">Link 112</a>
<a href="#" id="113">Link 113</a>
<a href="#" id="114">Link 114</a>
<a href="#" id="115">Link 115</a>
<a href="#" id="116">Link 116</a>
<a href="#" id="117">Link 117</a>
<a href="#" id="118">Link 118</a>
<a href="#" id="119">Link 119</a>
<a href="#" id="120">Link 120</a>
<a href="#" id="121">Link 121</a>
<a href="#" id="122">Link 122</a>
<a href="#" id="123">Link 123</a>
<a href="#" id="124">Link 124</a>
<a href="#" id="125">Link 125</a>
<a href="#" id="126">Link 126</a>
<a href="#" id="127">Link 127</a>
<a href="#" id="128">Link 128</a>
<a href="#" id="129">Link 129</a>
<a href="#" id="130">Link 130</a>
<a href="#" id="131">Link 131</a>
<a href="#" id="132">Link 132</a>
<a href="#" id="133">Link 133</a>
<a href="#" id="134">Link 134</a>
<a href="#" id="135">Link 135</a>
<a href="#" id="136">Link 136</a>
<a href="#" id="137">Link 137</a>
<a href="#" id="138">Link 138</a>
<a href="#" id="139">Link 139</a>
<a href="#" id="140">Link 140</a>
<a href="#" id="141">Link 141</a>
<a href="#" id="142">Link 142</a>
<a href="#" id="143">Link 143</a>
<a href="#" id="144">Link 144</a>
<a href="#" id="145">Link 145</a>
<a href="#" id="146">Link 146</a>
<a href="#" id="147">Link 147</a>
<a href="#" id="148">Link 148</a>
<a href="#" id="149">Link 149</a>
<a href="#" id="150">Link 150</a>
<a href="#" id="151">Link 151</a>
<a href="#" id="152">Link 152</a>
<a href="#" id="153">Link 153</a>
<a href="#" id="154">Link 154</a>
<a href="#" id="155">Link 155</a>
<a href="#" id="156">Link 156</a>
<a href="#" id="157">Link 157</a>
<a href="#" id="158">Link 158</a>
<a href="#" id="159">Link 159</a>
<a href="#" id="160">Link 160</a>
<a href="#" id="161">Link 161</a>
<a href="#" id="162">Link 162</a>
<a href="#" id="163">Link 163</a>
<a href="#" id="164">Link 164</a>
<a href="#" id="165">Link 165</a>
<a href="#" id="166">Link 166</a>
<a href="#" id="167">Link 167</a>
<a href="#" id="168">Link 168</a>
<a href="#" id="169">Link 169</a>
<a href="#" id="170">Link 170</a>
<a href="#" id="171">Link 171</a>
<a href="#" id="172">Link 172</a>
<a href="#" id="173">Link 173</a>
<a href="#" id="174">Link 174</a>
<a href="#" id="175">Link 175</a>
<a href="#" id="176">Link 176</a>
<a href="#" id="177">Link 177</a>
<a href="#" id="178">Link 178</a>
<a href="#" id="179">Link 179</a>
<a href="#" id="180">Link 180</a>
<a href="#" id="181">Link 181</a>
<a href="#" id="182">Link 182</a>
<a href="#" id="183">Link 183</a>
<a href="#" id="184">Link 184</a>
<a href="#" id="185">Link 185</a>
<a href="#" id="186">Link 186</a>
<a href="#" id="187">Link 187</a>
<a href="#" id="188">Link 188</a>
<a href="#" id="189">Link 189</a>
<a href="#" id="190">Link 190</a>
<a href="#" id="191">Link 191</a>
<a href="#" id="192">Link 192</a>
<a href="#" id="193">Link 193</a>
<a href="#" id="194">Link 194</a>
<a href="#" id="195">Link 195</a>
<a href="#" id="196">Link 196</a>
<a href="#" id="197">Link 197</a>
<a href="#" id="198">Link 198</a>
<a href="#" id="199">Link 199</a>
 

Preparation code output

Link 0 Link 1 Link 2 Link 3 Link 4 Link 5 Link 6 Link 7 Link 8 Link 9 Link 10 Link 11 Link 12 Link 13 Link 14 Link 15 Link 16 Link 17 Link 18 Link 19 Link 20 Link 21 Link 22 Link 23 Link 24 Link 25 Link 26 Link 27 Link 28 Link 29 Link 30 Link 31 Link 32 Link 33 Link 34 Link 35 Link 36 Link 37 Link 38 Link 39 Link 40 Link 41 Link 42 Link 43 Link 44 Link 45 Link 46 Link 47 Link 48 Link 49 Link 50 Link 51 Link 52 Link 53 Link 54 Link 55 Link 56 Link 57 Link 58 Link 59 Link 60 Link 61 Link 62 Link 63 Link 64 Link 65 Link 66 Link 67 Link 68 Link 69 Link 70 Link 71 Link 72 Link 73 Link 74 Link 75 Link 76 Link 77 Link 78 Link 79 Link 80 Link 81 Link 82 Link 83 Link 84 Link 85 Link 86 Link 87 Link 88 Link 89 Link 90 Link 91 Link 92 Link 93 Link 94 Link 95 Link 96 Link 97 Link 98 Link 99 Link 100 Link 101 Link 102 Link 103 Link 104 Link 105 Link 106 Link 107 Link 108 Link 109 Link 110 Link 111 Link 112 Link 113 Link 114 Link 115 Link 116 Link 117 Link 118 Link 119 Link 120 Link 121 Link 122 Link 123 Link 124 Link 125 Link 126 Link 127 Link 128 Link 129 Link 130 Link 131 Link 132 Link 133 Link 134 Link 135 Link 136 Link 137 Link 138 Link 139 Link 140 Link 141 Link 142 Link 143 Link 144 Link 145 Link 146 Link 147 Link 148 Link 149 Link 150 Link 151 Link 152 Link 153 Link 154 Link 155 Link 156 Link 157 Link 158 Link 159 Link 160 Link 161 Link 162 Link 163 Link 164 Link 165 Link 166 Link 167 Link 168 Link 169 Link 170 Link 171 Link 172 Link 173 Link 174 Link 175 Link 176 Link 177 Link 178 Link 179 Link 180 Link 181 Link 182 Link 183 Link 184 Link 185 Link 186 Link 187 Link 188 Link 189 Link 190 Link 191 Link 192 Link 193 Link 194 Link 195 Link 196 Link 197 Link 198 Link 199

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jquery select id
for (var i = 0; i < 200; i++) {
 jQuery("#" + i);
}
pending…
getElementByID
for (var i = 0; i < 200; i++) {
 document.getElementById('a' + i);
}
pending…
dojo 1.5 select Id
for (var i = 0; i < 200; i++) {
 dojo.byId("#" + i);
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment