define('DISALLOW_FILE_EDIT', true); Share This sans-prototype.js – unFocus Projects – Kevin Newman and Ken Newman

Share This sans-prototype.js

I had a planed to replace the use of Prototype.js in the Share This WordPress plugin, since that was the only plugin using it. Prototype is quite large, and my server isn’t currently set up to gzip javascript files. I started to replace it with jQuery, and add an option to switch between the two. I figured it’d be a good way to help make the blog load more quickly if I make sure all the plugins were using the same (smaller) JavaScript framework.

I found along the way that Share This doesn’t actually use very much of Prototype.js at all. It does a few id based element queries, and uses Prototype’s Position.cumulativeOffset once. So I just converted the dollar sign based id query with DOM standard getElementById, and replaced the cumulativeOffset method call. Then removed the bits that output a prototype.js header link.

That’s it. No more bulky prototype.js dependency!

You can grab the patch from the WP Plugins trac.

While I was at it, I also added gzip support for the js, css and static share-this page, along with a new flag to turn gzip on and off.

Here’s the gzip support patch.

If you’d rather skip all the patching, here is a prepatched share-this.php archive. To use it, download the Share This plugin, and overwrite share-this.php with the new one (patched against the latest from SVN as of this post date).

Author: Kevin Newman

I'm the lead developer at adcSTUDIO located in Kingston NY (in Livingston Manor NY before that). I do all kinds of things there, from robust server side work to the much more enjoyable client side development in HTML/JavaScript/Flash (RIAs, HTML5, etc.) and all the other tech-buzz-phrases of the moment. My brother came up with the idea for unFocus.com which was originally meant be a place to discuss and blog about whatever topics we both found interesting, from politics to technology, to art and design. Time was scarce, and I need a place to host History Keeper, and unFocus Projects - a sub focus of unfocus.com was born, and eventually migrated to the font page. Oh, and I'm on Twitter (@Touvan) and Google+.

Leave a Reply

Your email address will not be published. Required fields are marked *