Only 5 of my plugins (WP-Polls, WP-PostRatings, WP-Email, WP-ServerInfo and WP-UserOnline) use JavaScript. The JavaScripts are packed using Dean Edward’s Packer and the only framework use just for AJAX is TW-Sack or Simple AJAX Code-Kit (SACK). TW-Sack is extremely lightweight and easy to use but unfortunately, it can be used only for AJAX purposes. The reason I used TW-Sack instead of jQuery is simple, at the time I created my plugin, jQuery does not exists yet and when jQuery becomes popular the reason why I didn’t upgrade it was because I was lazy. As the saying goes, “If it ain’t broke, don’t fix it”. Recently there is some buzz within the WordPress Development Team regarding WordPress’s JavaScript Usage. Andrew Ozz has written two articles on it in the WordPress Development Updates blog entitled Optimizing script loading, Optimizing script loading part 2 and Optimizing script loading, implementation. With the upcoming WordPress 2.8 will feature some heavy JavaScript changes, I told myself to make use of this chance to totally revamped the JavaScripts in my plugins. Here are the changes that will be made:
- Minified JavaScript instead of packing them
- Replaced TW-Sack with jQuery
- Move JavaScript to the footer
- Use wp_localize_script() for JavaScript text translation
- javascript-js.js will now contain the minified code for normal usage
- javascript-js.dev.js will now contain the unminified code for development purposes
I have already done it for WP-PostRatings and it is now running live on this site. Next, I will be doing WP-UserOnline, followed by WP-Email and lastly WP-Polls as it is more complex.
Tags: footer, Javascript, minify, packed
 




(100 votes, average: 3.89 out of 5)
I just wanted to find a place to send you a comment somewhere… your plugins are great! Just wanted to say thank you!!
Thank You =)
[...] Preparing for WordPress 2.8: Using JavaScript in WordPress Plugins [...]
Thanks a tonne for the information about JavaScript In My Plugins. It is much needed for wordpress bloggers
[...] Preparing for WordPress 2.8: Using JavaScript in WordPress Plugins [...]
[...] Chan has tips for using JavaScript in WordPress Plugins for WordPress [...]
[...] Chan has tips for using JavaScript in WordPress Plugins for WordPress [...]
[...] Script Loading Optimizing script loading part 2 Optimizing script loading, implementation Preparing for WordPress 2.8: Using JavaScript in WordPress Plugins Change your WordPress Theme on … WordPress 2.8 body_class, automatic_feed_links What a [...]
Great plugin. Thank you very much
Hi just looked through your web page http://lesterchan.net/ and noticed the accordian menu – can anybody tell me if it is available for wordpress using the Atahualpa 3.3.2 theme
Thanks
[...] JavaScript In My Plugins Lester Chan WordPress Plugins Posted by root 2 hours ago (http://lesterchan.net) Jan 15 2009 i just wanted to find a place to send you a comment somewhere your plugins are great international wordpress tv lorelle on wordpress says lester chan wordpress plugins is proudly powered by wordpress Discuss | Bury | News | JavaScript In My Plugins Lester Chan WordPress Plugins [...]
Nice to see a lot of java plugins for word pres.. But i am using a blogger blog for govt employees news. Can these java plugings can be used for blogger blogs also..??
hmm I have no idea on that.