{"action":"created","issue":{"url":"https://api.github.com/repos/jquery/jquery/issues/2042","labels_url":"https://api.github.com/repos/jquery/jquery/issues/2042/labels{/name}","comments_url":"https://api.github.com/repos/jquery/jquery/issues/2042/comments","events_url":"https://api.github.com/repos/jquery/jquery/issues/2042/events","html_url":"https://github.com/jquery/jquery/issues/2042","id":55836075,"number":2042,"title":"elem.is(':visible') calls native webkitMatchesSelector","user":{"login":"paulirish","id":39191,"avatar_url":"https://avatars.githubusercontent.com/u/39191?v=3","gravatar_id":"","url":"https://api.github.com/users/paulirish","html_url":"https://github.com/paulirish","followers_url":"https://api.github.com/users/paulirish/followers","following_url":"https://api.github.com/users/paulirish/following{/other_user}","gists_url":"https://api.github.com/users/paulirish/gists{/gist_id}","starred_url":"https://api.github.com/users/paulirish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulirish/subscriptions","organizations_url":"https://api.github.com/users/paulirish/orgs","repos_url":"https://api.github.com/users/paulirish/repos","events_url":"https://api.github.com/users/paulirish/events{/privacy}","received_events_url":"https://api.github.com/users/paulirish/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-29T00:04:19Z","updated_at":"2015-01-29T02:26:52Z","closed_at":null,"body":"Yesterday I spent some time profiling the effect shown in this article:\r\nhttp://engineeringblog.yelp.com/2015/01/animating-the-mobile-web.html  (and here's [the live m.yelp page](http://m.yelp.com/biz/soma-eats-san-francisco))\r\n\r\n![image](https://cloud.githubusercontent.com/assets/39191/5949764/3fbd1230-a706-11e4-844d-56c5d5457034.png)\r\n\r\nDuring profiling I some interesting things, but two of which are specific to jQuery.\r\n1) `webKitMatchesSelector` is being called during `elem.is(':visible')` \r\n2 ) jQuery handler for `touchmove` seems very slow. (This one we can punt to another ticket.)\r\n\r\nA closer look at the `is` to `matchesSelector` stack:\r\n![image](https://cloud.githubusercontent.com/assets/39191/5949796/8c5c35e4-a706-11e4-8ac3-da8d87530b3f.png)\r\n\r\nHere's the `a.rl` method we're looking at:\r\n\r\n```js\r\na.rl = function(b) {\r\n            return b.qu.is(\":visible\") || b.Ts.is(\":visible\")\r\n        };\r\n```\r\n\r\nIn total, this stack from `a.rl` through `webKitMatchesSelector` accounts for a full 15% of all time on CPU (including JS, recalc, paint, etc) during this effect, so certainly not trivial.\r\n\r\n\r\nBut this still strikes me as odd in the first place.\r\n\r\nI don't think we would ever want a native qSA or matchesSelector to handle this sort of call, would we?\r\n"},"comment":{"url":"https://api.github.com/repos/jquery/jquery/issues/comments/71958246","html_url":"https://github.com/jquery/jquery/issues/2042#issuecomment-71958246","issue_url":"https://api.github.com/repos/jquery/jquery/issues/2042","id":71958246,"user":{"login":"dmethvin","id":157858,"avatar_url":"https://avatars.githubusercontent.com/u/157858?v=3","gravatar_id":"","url":"https://api.github.com/users/dmethvin","html_url":"https://github.com/dmethvin","followers_url":"https://api.github.com/users/dmethvin/followers","following_url":"https://api.github.com/users/dmethvin/following{/other_user}","gists_url":"https://api.github.com/users/dmethvin/gists{/gist_id}","starred_url":"https://api.github.com/users/dmethvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmethvin/subscriptions","organizations_url":"https://api.github.com/users/dmethvin/orgs","repos_url":"https://api.github.com/users/dmethvin/repos","events_url":"https://api.github.com/users/dmethvin/events{/privacy}","received_events_url":"https://api.github.com/users/dmethvin/received_events","type":"User","site_admin":false},"created_at":"2015-01-29T02:26:52Z","updated_at":"2015-01-29T02:26:52Z","body":"I'll pull in @timmywil and @gibson042 here, maybe we could do a quick regex to look for obvious offenders? Discussing the issue in IRC, perhaps we should move things like `:hidden` and other really slow custom selectors to jQuery Migrate in 4.0. Of course that brings up some Sizzle questions as well."}}