jQuery URL Shorten Plugin Using Bit.ly API - Bitlr

File Size: 3.2 KB
Views Total: 2912
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery URL Shorten Plugin Using Bit.ly API - Bitlr

Just another lightweight jQuery plugin used to shorten long URL using Bit.ly URL shortening service.

See also:

How to use it:

1. Include the jQuery library and the jQuery bitlr plugin at the bottom of the document.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="src/bitlr.js"></script>

2. Create an element to output the shortened URL.

<div class="short-url">Short URL: <span></span></div>

3. The javascript to shorten a long URL.

<script>
$.bitlr({
apiKey: 'YOUR BIT.LY API KEY',
link: 'https://www.jqueryscript.net', // the link you'd like to shorten.
anchor: true, // A boolean value that indicates whether or not the shortened link should be returned as an anchor
success: function(newLink) {
$('.short-url span').html(newLink);
},
});
</script>

This awesome jQuery plugin is developed by michael-lynch. For more Advanced Usages, please check the demo page or visit the official website.