neilco / twix

Twix is a lightweight JavaScript library for making AJAX requests. With teeth.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Twix

Twix is a lightweight JavaScript library for making AJAX requests in places where jQuery won't go.

★ Don't let its tiny size deceive you ★

It may weigh-in at just over 1KB, but this puppy has teeth. WOOF!

Modelled after the ubiquitious jQuery's AJAX methods ($.ajax, $.get, $.post, _$.patch, $.put, $.delete and $.options), you can use this in places were jQuery will not load, such as inside a WebWorker#. You little ripper!

You may be like me and occasionally think that loading the entire jQuery library (about 80KB minified) just to make an AJAX call is just like filling a thimble using a fire hydrant. Twix is written from the ground up to work in modern browsers (IE9+, Firefox, Chrome, Safari, etc. Anything that supports XMLHttpRequest, really) and has just enough magic sauce to get the job done. No more, no less.


# Actually, providing a simple way to make make AJAX calls inside a WebWorker was the primary use-case when developing this golden nugget. How about that.

Usage

Simply add a reference to twix.js or twix.min.js and you're good to go.

<script type="text/javascript" src="twix.min.js"></script>

If you want to make an AJAX call from within a WebWorker, load the Twix library using the importScripts function:

importScripts("twix.min.js");

Making an AJAX request is as simple as calling Twix.ajax(...) or Twix.get(...) or Twix.post(...). If typing the four characters of Twix is too much, you use the optional double-underscore (__.ajax(...)) shortcut.

There's an ultra-basic sample of making a GET request from a WebWorker in the sample directory.

Contributors

Well, it's just me. It's a little lonely, so feel free to issue a pull request with fixes or enhancements and get your name listed here.

Why Twix?

Because two chocolatey fingers are better than one.

License

MIT license

Copyright (c) 2013 Neil Cowburn (http://github.com/neilco/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Twix is a lightweight JavaScript library for making AJAX requests. With teeth.

License:MIT License


Languages

Language:JavaScript 100.0%