Browse Source

Query for `<img>` elements only

While this is probably a case of micro-optimisation, [there is a performance gain of some 5%](http://jsperf.com/queryselectorall-with-attr-only-and-with-element-type) when querying for `img[data-echo]` as opposed to `[data-echo]` only.
pull/42/head
Valentin Zwick 11 years ago
parent
commit
c77fc689b5
  1. 2
      src/echo.js

2
src/echo.js

@ -76,7 +76,7 @@ window.Echo = (function (global, document, undefined) {
*/ */
var init = function (obj) { var init = function (obj) {
var nodes = document.querySelectorAll('[data-echo]'); var nodes = document.querySelectorAll('img[data-echo]');
var opts = obj || {}; var opts = obj || {};
offset = parseInt(opts.offset || 0); offset = parseInt(opts.offset || 0);
throttle = parseInt(opts.throttle || 250); throttle = parseInt(opts.throttle || 250);

Loading…
Cancel
Save