Use this wrapper when you need to merge your scripts at build time, and you need Zepto but full-jQuery is not required.
This wrapper optimistically loads Zepto.js inline, but then suppresses its execution and lazily loads jQuery from a CDN (Google Ajax API) if the environment is unsupported.
All versions of Internet Explorer are officially not supported by Zepto. Unfortunately, IE8 and earlier throw exceptions if it is even loaded.
This is just a simple bash script and has only really been tested on Mac OS X using Homebrew for Node. In other environments, YMMV. Commented out is a test/auto-install for Node.js/NPM. Ideally, I'd put it into something more portable, or use Zepto's setup, but this did the trick for me. As it is, the README is larger than the script.
If you want to modify where jQuery is loaded from, just tweak unsupported.js
. It should be easy to find.
If you want a different set of build modules than the default Zepto builds, just edit the MODULES
varible in build.sh
. For example, I prefer to remove detect
and fx
.
By default these are the included modules:
- intro - start of the wrapper
- unsupported - supported test and jQuery lazy loader
- zepto
- event
- detect
- fx
- ajax
- form
- outro - end of the wrapper
I prefer to use minification / obfuscation mechanisms, so I don't bother to keep my variables short or hang onto zepto.min.js
.
If you subscribe to idiomatic Zepto formatting, you probably won't like my work.
Feel free to tweak to your needs, just don't expect me to accept a pull request to remove semicolons, etc.
Zepto-wrapper is licensed under the terms of the MIT License.