{"id":18013007,"url":"https://github.com/hackwaly/q","last_synced_at":"2025-06-21T22:02:31.285Z","repository":{"id":146287361,"uuid":"2135401","full_name":"hackwaly/Q","owner":"hackwaly","description":"blazing fast jit compile javascript css selector!","archived":false,"fork":false,"pushed_at":"2011-11-02T07:52:44.000Z","size":284,"stargazers_count":24,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T20:56:08.965Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackwaly.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-01T06:27:57.000Z","updated_at":"2023-11-03T17:09:16.000Z","dependencies_parsed_at":"2023-03-23T22:32:41.849Z","dependency_job_id":null,"html_url":"https://github.com/hackwaly/Q","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hackwaly/Q","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2FQ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2FQ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2FQ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2FQ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackwaly","download_url":"https://codeload.github.com/hackwaly/Q/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2FQ/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261200319,"owners_count":23123942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T03:19:38.846Z","updated_at":"2025-06-21T22:02:26.263Z","avatar_url":"https://github.com/hackwaly.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"1, 和Sizzle的兼容\nQ(expr, context, result, seed)\nQ.matches\n支持Sizzle特别的setFilter伪类如:even,:first,:last,:lt...\n支持复杂的:not和:has选择器（和sizzle一样）\n\n2, 结果的正确性\nSizzle在某些选择器上由于查询策略的原因，会返回错误的结果\n考虑在这样的html上查询\n\"\u003cdiv/\u003e\u003ch1/\u003e\u003ch1/\u003e\u003cdiv/\u003e\"\n查询 div~div : 应返回1个节点\n查询 h1~div: 应返回1个节点\n查询 div+h1~div: 应返回一个节点，但是Sizzle没有找到节点\n\n另外\ndiv.querySelectorAll(\"body *\")会返回节点\n所以在以元素为context的查询中不使用querySelectorAll进行优化\n\n3, 性能\n将选择器编译成函数再进行查询，除了第一次查询需要jit编译之外，以后每次查询都是最快的速度\n查询策略引擎会分析选择器的组成，选择最恰当的查询策略（从开始查还是从末尾查还是从中间开始）\n排除不必要的运算，如sizzle中的:lt伪类，这里查询时找够节点就会跳出查询，不会继续做无谓的查询\n\n可以参考slickspeed.\nhttp://jselector.googlecode.com/svn/trunk/jsslickspeed/index.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackwaly%2Fq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackwaly%2Fq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackwaly%2Fq/lists"}