Benchmark jQuery 1.11.0 vs 3.7.1
Benchmark jQuery 1.11.0 vs 3.7.1
{"ScriptPreparationCode":"function setupElements() {\r\n const container = $(\u0027#container\u0027);\r\n container.empty();\r\n\r\n // Cria muitos elementos para manipula\u00E7\u00E3o\r\n for (let i = 0; i \u003C 100000; i\u002B\u002B) {\r\n container.append(\u0027\u003Cdiv class=\u0022item\u0022\u003EItem \u0027 \u002B i \u002B \u0027\u003C/div\u003E\u0027);\r\n }\r\n}\r\n\r\n// Benchmark com jQuery 1.11.0 usando .bind()\r\nfunction runBenchmarkWithBind() {\r\n setupElements();\r\n const start = performance.now();\r\n $(\u0027.item\u0027).bind(\u0027click\u0027, function() {\r\n $(this).toggleClass(\u0027highlight\u0027);\r\n });\r\n const end = performance.now();\r\n const duration = end - start;\r\n document.getElementById(\u0027result-jquery-1\u0027).textContent = \r\n \u0060Vers\u00E3o 1.11.0 (.bind) levou ${duration.toFixed(2)} ms para vincular eventos a 10.000 elementos.\u0060;\r\n}\r\n\r\n// Benchmark com jQuery 3.7.1 usando .on()\r\nfunction runBenchmarkWithOn() {\r\n setupElements();\r\n const start = performance.now();\r\n $(\u0027.item\u0027).on(\u0027click\u0027, function() {\r\n $(this).toggleClass(\u0027highlight\u0027);\r\n });\r\n const end = performance.now();\r\n const duration = end - start;\r\n document.getElementById(\u0027result-jquery-3\u0027).textContent = \r\n \u0060Vers\u00E3o 3.7.1 (.on) levou ${duration.toFixed(2)} ms para vincular eventos a 10.000 elementos.\u0060;\r\n}","TestCases":[{"Name":"1.11.0","Code":"runBenchmarkWithBind()","IsDeferred":false},{"Name":"3.7.1","Code":"runBenchmarkWithOn();","IsDeferred":false}]}