[wp-hackers] Standard JavaScript

Robert Deaton false.hopes at gmail.com
Thu Aug 17 16:27:29 GMT 2006


On 8/17/06, Mike Purvis <mike at uwmike.com> wrote:
> Hi everyone,
>
> I just wanted to inquire as to the state of a "standard JavaScript"
> initiative for Wordpress. I've noticed that many plugins--both admin-
> and public-facing--include common functions like the AJAX try-catch
> block, and this seem unnecessarily wasteful.

With 2.1, they definitely shouldn't. The new script loader is made to
handle this (on the admin side at least). On the public side, the
libraries are still there and available.

> I like that the WP admin area includes addLoadEvent, and I guess I'm
> just wondering if there'd be interest in either creating a small WP JS
> library, or adopting one, such as Prototype/Behaviour.

Prototype 1.5.0 out of their SVN repository is in the core. (We're
using unstable because 1.4.0 and TinyMCE do not play along well
together).

> It could be "not in the header" by default, but any plugin or theme
> could call a function (before output starts) that causes the link to
> be included, both on the public side and admin panel.

wp_enqueue_script

> Finally, I've noticed a lot of plugins that insert great gobs of JS
> and CSS directly into the header, rather than referencing external,
> cache-able locations. The get_plugininfo would help make this easier,
> but in the meantime, you could do a trick like the WP-Cats plugin,
> where the "external" locations are just GET parameters on the root of
> the blog, eg:

I agree, they should be spitting out a cachable JS file.

> <http://uwmike.com/?wp-cats=css> and <http://uwmike.com/?wp-cats=js>
>
> Doing this keeps the main markup clean, and it also lets the whole
> plugin be packaged neatly into a single PHP file. But it would be
> helpful to have a way to "trigger" the availability of certain
> oft-used JS functions.

-- 
--Robert Deaton


More information about the wp-hackers mailing list