• This repository has been archived on 10/Nov/2017
  • Stars
    star
    215
  • Rank 183,220 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jQuery SelectorSet patch

Speeds up jQuery event delegation by using SelectorSet for matching event targets.

Installation

Available on Bower as jquery-selector-set.

$ bower install jquery-selector-set

This should also download the dependencies, jquery and selector-set.

Alternatively you can download the jquery.selector-set.js and selector-set.js files individually. I'll assume you probably already have jQuery itself setup at this point.

$ curl -O https://raw.github.com/josh/jquery-selector-set/master/jquery.selector-set.js
$ curl -O https://raw.github.com/josh/selector-set/master/selector-set.js

Usage

There are no new APIs, use jQuery event handlers as you would.

Be sure to load the patch right after you load jQuery.

<script src="jquery.js"></script>
<script src="selector-set.js"></script>
<script src="jquery.selector-set.js"></script>
<script src="app/foo.js"></script>
<script src="app/bar.js"></script>

Supported jQuery versions

This plugin is currently tested on jQuery 1.8.x, 1.9.x, 1.10.x, 2.0.x and 2.1.x.

Performance

This patch improves the event dispatch code path for delegated jQuery event handlers. For any user event, click, keydown, etc, jQuery.event.dispatch is invoked. This also applies to custom events using trigger: $(el).trigger('menu.open').

This jsPerf shows a typical GitHub code snippet (a typical deeply nested tree) and a handful of globally delegated selectors.

http://jsperf.com/jquery-selector-set-trigger

Development

Clone the repository from GitHub.

$ git clone https://github.com/josh/jquery-selector-set

You'll need to have Grunt installed. If you don't have the grunt executable available, you can install it with:

$ npm install -g grunt-cli

Now just cd into the directory and install the local npm dependencies.

$ cd jquery-selector-set/
$ npm install

Use grunt test to run the test suite.

$ grunt test
Running "jshint:all" (jshint) task
>> 5 files lint free.

Running "qunit:all" (qunit) task
Testing test/test.html .....................OK
>> 100 assertions passed (50ms)

Done, without errors.

License

Copyright (c) 2013 Joshua Peek

Distributed under an MIT-style license. See LICENSE for details.

More Repositories

1

css-explain

SQL EXPLAIN for CSS selectors
JavaScript
1,069
star
2

selector-set

JavaScript
279
star
3

rails-behaviors

Rails UJS Behaviors for jQuery and Zepto
CoffeeScript
271
star
4

selector-observer

Allows you to monitor DOM elements that match a CSS selector
JavaScript
217
star
5

overcast-sonos

Listen to your Overcast podcasts on Sonos.
PHP
183
star
6

nack

Node powered Rack server
CoffeeScript
172
star
7

Aware

A simple menubar app for OSX and macOS that tracks how long you've been actively using your computer
Swift
143
star
8

launchdns

A launchd friendly development DNS server
Shell
75
star
9

dotfiles

My $HOME
Shell
63
star
10

imdb-trakt-sync-broken

Sync IMDb to Trakt
Shell
53
star
11

scroll-anchoring

Preserves the user's scroll position while DOM mutations change the page.
HTML
50
star
12

tickerd

A Docker process scheduler
Go
12
star
13

swift-har

A Swift library for encoding, decoding, recording and testing using the HTTP Archive format.
Swift
10
star
14

icloud-backup-utils

Scripts creating backups of iCloud data.
Shell
8
star
15

google-domains-ddns

Dockerfile
7
star
16

workflows

Reusable workflows for GitHub Actions
6
star
17

smtp2webhook

SMTP to Webhook Relay
Go
6
star
18

csv2json

A humble CSV tool, friend of jq
Swift
6
star
19

displayrcd

Run a script when your Mac changes displays
Swift
5
star
20

offlineimap-gmail

Dockerfile
3
star
21

trakt-plex-sync

Sync Trakt history to Plex library
Python
3
star
22

homeassistant-healthchecks

Home Assistant custom component for Healthchecks.io
Python
3
star
23

josh

My GitHub profile
2
star
24

wikidatabots

Wikidata bots running under Josh404Bot
Python
2
star
25

docker-ondemand

Lazily start and automatically stop Docker for Mac
Shell
2
star
26

ConsoleKit

An embeddable SwiftUI OSLog view
Swift
2
star
27

homebrew-tap

Homebrew custom formulas for @josh repositories.
Ruby
2
star
28

mixnmatch-catalogs

Python
2
star
29

itunes-library-export

A command line tool to export iTunes Library XML files.
Swift
2
star
30

wikidata-api-schemas

Wikidata JSON Schemas
Shell
1
star
31

joshpeek.com

Just a bunch of redirects
Dockerfile
1
star
32

smtp2workflow

SMTP to GitHub Actions workflow Relay
Go
1
star
33

us-state-travel-advisories-feeds

JSON feeds for U.S. Department of State Travel Advisories
Python
1
star
34

alamo-drafthouse-feeds

JSON feeds for Alamo Drafthouse showings
Python
1
star
35

overcast-data

Overcast podcast personal data scraper
Python
1
star
36

imdb-plex-sync

Sync IMDb watchlist to Plex watchlist
Python
1
star
37

imdb-data

IMDB personal lists and ratings data scaper
Python
1
star