{"action":"opened","issue":{"url":"https://api.github.com/repos/madrobby/zepto/issues/1185","repository_url":"https://api.github.com/repos/madrobby/zepto","labels_url":"https://api.github.com/repos/madrobby/zepto/issues/1185/labels{/name}","comments_url":"https://api.github.com/repos/madrobby/zepto/issues/1185/comments","events_url":"https://api.github.com/repos/madrobby/zepto/issues/1185/events","html_url":"https://github.com/madrobby/zepto/issues/1185","id":144290877,"number":1185,"title":"if $('xxx') should cache","user":{"login":"493636333","id":8940347,"avatar_url":"https://avatars.githubusercontent.com/u/8940347?v=3","gravatar_id":"","url":"https://api.github.com/users/493636333","html_url":"https://github.com/493636333","followers_url":"https://api.github.com/users/493636333/followers","following_url":"https://api.github.com/users/493636333/following{/other_user}","gists_url":"https://api.github.com/users/493636333/gists{/gist_id}","starred_url":"https://api.github.com/users/493636333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/493636333/subscriptions","organizations_url":"https://api.github.com/users/493636333/orgs","repos_url":"https://api.github.com/users/493636333/repos","events_url":"https://api.github.com/users/493636333/events{/privacy}","received_events_url":"https://api.github.com/users/493636333/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-29T14:57:17Z","updated_at":"2016-03-29T14:57:17Z","closed_at":null,"body":"usually，we use $('xxx') to select element,but we repeat selecting same elements many time.\r\nexample:\r\nfunction show () {\r\n    $('xxx').show();\r\n}\r\nfunction hide() {\r\n    $('xxx').hide();\r\n}\r\nThis brings performance loss，many time we write in this way:\r\nvar $xxx = $('xxx');\r\nfunction show () {\r\n    $xxx.show();\r\n}\r\nfunction hide() {\r\n    $xxx.hide();\r\n}\r\nbut if function nested layers too deep, also brings performance loss.\r\nand AMD or CMD let us can't cache elements.\r\nso if we should cache elements in '$' function,although  element can be removed.\r\nbut we can provide an argument to chose if we find element again。\r\nlike this: $('xxx',true);\r\nwe use selector in many events,so it doesn't matter that we cache elements,because it needs.\r\nso we can use $('xxx') every time and don't have to worry about performance。"}}