{"id":240,"date":"2009-01-15T01:50:53","date_gmt":"2009-01-14T17:50:53","guid":{"rendered":"http:\/\/lesterchan.net\/wordpress\/?p=240"},"modified":"2009-01-19T19:02:48","modified_gmt":"2009-01-19T11:02:48","slug":"javascript-in-my-plugins","status":"publish","type":"post","link":"https:\/\/lesterchan.net\/wordpress\/2009\/01\/15\/javascript-in-my-plugins\/","title":{"rendered":"JavaScript In My Plugins"},"content":{"rendered":"<p>Only 5 of my plugins (WP-Polls, WP-PostRatings, WP-Email, WP-ServerInfo and WP-UserOnline) use JavaScript. The JavaScripts are packed using <a href=\"http:\/\/dean.edwards.name\/packer\/\">Dean Edward&#8217;s Packer<\/a> and the only framework use just for AJAX is <a href=\"http:\/\/www.twilightuniverse.com\/projects\/sack\/\">TW-Sack or Simple AJAX Code-Kit (SACK)<\/a>. 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&#8217;t upgrade it was because I was lazy. As the saying goes, &#8220;If it ain&#8217;t broke, don&#8217;t fix it&#8221;.  Recently there is some buzz within the WordPress Development Team regarding WordPress&#8217;s JavaScript Usage. Andrew Ozz has written two articles on it in the <a href=\"http:\/\/wpdevel.wordpress.com\/\">WordPress Development Updates<\/a> blog entitled <a href=\"http:\/\/wpdevel.wordpress.com\/2008\/12\/27\/optimizing-script-loading\/\">Optimizing script loading<\/a>, <a href=\"http:\/\/wpdevel.wordpress.com\/2009\/01\/07\/optimizing-script-loading-part-2\/\">Optimizing script loading part 2<\/a> and <a href=\"http:\/\/wpdevel.wordpress.com\/2009\/01\/15\/optimizing-script-loading-implementation\/\">Optimizing script loading, implementation<\/a>.  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:<\/p>\n<ul>\n<li>Minified JavaScript instead of packing them<\/li>\n<li>Replaced TW-Sack with jQuery<\/li>\n<li>Move JavaScript to the footer<\/li>\n<li>Use wp_localize_script() for JavaScript text translation<\/li>\n<li>javascript-js.js will now contain the minified code for normal usage<\/li>\n<li>javascript-js.dev.js will now contain the unminified code for development purposes<\/li>\n<\/ul>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;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 &hellip; <a href=\"https:\/\/lesterchan.net\/wordpress\/2009\/01\/15\/javascript-in-my-plugins\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;JavaScript In My Plugins&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,19,9],"tags":[111,109,110,112],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-plugins","category-wordpress","category-wp-postratings","tag-footer","tag-javascript","tag-minify","tag-packed"],"views":20297,"_links":{"self":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":0,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"wp:attachment":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}