twitter/bootstrap — pull request #7652 by mgcrea (2013-04-21 21:38:02+00:00)
Title: Drop the sizzle dependency to allow smaller builds targeting mobile devices

It would be great if on the javascript side, for the 3.0 release, bootstrap could drop the `sizzle` dependency. We can now easily get custom smaller jQuery builds. It would make sense with being "mobile first" where KBs matter a lot.

I'm currently reviewing a custom jquery2+bootstrap build for [AngularStrap](http://mgcrea.github.io/angular-strap/) to pave the way for mobile apps there. Looks like most of bootstrap's javascript works with this custom build:

grunt custom:-ajax,-deprecated,-effects,-sizzle

This gives a 17KB file (min+gz) vs. 29KB, thus -42%. That's great and the jquery modularization/cleanup is only beginning.

---

If we take a look at the current [`bootstrap-tab.js`](https://github.com/twitter/bootstrap/blob/v2.3.1/js/bootstrap-tab.js) implementation for the `v2.3.1` release, to make it work with a sizzle-free build, we have to:

1. replace `> .class` with `children()`:

[bootstrap-tab.js l.82](https://github.com/twitter/bootstrap/blob/v2.3.1/js/bootstrap-tab.js#L82)

``` javascript
.find('> .dropdown-menu > .active') // unsupported
```

could be replace with:

``` javascript
.children('.dropdown-menu').children('.active')
```

2. find a sizzle-free alternative to some positional selectors, `:first` & `:last` (that do not behave like the css3 `:first-child`, etc.).

[bootstrap-tab.js l.52](https://github.com/twitter/bootstrap/blob/v2.3.1/js/bootstrap-tab.js#L52)

``` javascript
previous = $ul.find('.active:last a')[0]
```

could become:

``` javascript
previous = $($ul.find('.active:last').get(-1)).find('a')[0]
```