Skip to content

jholster/qs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

qs

~200-byte selector engine

API

$('body').contentEditable = true                          # get single node
$('h1', parent).textContent = 'Hai!'                      # get single node from parent
$$ 'a'                                                    # get list of nodes
$$ 'a', (a) -> a.dataset.foo = 'bar'                      # loop through list of nodes
$$ 'p', parent, (child) -> child.classList.add 'hidden'   # loop through list of nodes from parent

Installation

<script>
  var $ = function(s, ctx) { var n = ctx || document; return n.querySelector.call(n, s) };
  var $$ = function(s, ctx, f) { if (undefined == f) f = ctx; var n = ctx || document; return Array.prototype.forEach.call(n.querySelectorAll.call(n, s), f) };
</script>

FAQ

How is this better than jQuery?

jQuery is amazing piece of software but adds tens of kilobytes of code for stuff already included in modern browsers.

About

~200-byte selector engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published