AJAX / JS libraries

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

AJAX / JS libraries

Ryan Scheuermann
Hey all,

With all the new AJAXy goodness and various Javascript tools and scripts
going into WP Admin 2.1, I feel as though adding a JS toolkit as a basis
for these JS calls might benefit plugin writers and also
consolidate/replace a lot of the JS scripts floating around.

I just read ringmaster's comments on Ticket #2654:

    If you're looking to implement something with Ajax, here's an idea:

    Ditch tw-sack (No error handling/debugging? Can't handle equals
    signs as passed values with the standard functions?) and build a
    WP-pluggable ajax library. Move all of the floating PHP functions
    that respond to the various ajax requests into a single file that
    dispatches those requests to plugin hooks. Include some way to hook
    client-side events to server-side code on-demand so that things like
    this can be customized by plugins.

No offense to whomever wrote all this wonderful AJAX and list management
code, but I fear the maintainability and extensibility of all this is
going to become a problem in future releases.  And if more AJAX is
planned for the future, I do think having a strong toolkit to build off
would be beneficial.  The phrase "don't reinvent the wheel" keeps coming
to mind.  Let the toolkit worry about handling cross-browser
compatibility, etc...

I don't know, maybe this has been discussed before or maybe the decision
was just made by those implementing it...  but for the sake of creating
an extensible and maintainable product that is now AJAX and JS friendly,
I think it should be considered.

Personally, I recommend Prototype.  http://prototype.conio.net/  It's
being used by the Widgets plugin and all the major applications running
Ruby on Rails (see any 37 Signals product), and I don't think it's
support is going to go away anytime soon.  And if you've ever seen
anything written using it, the JS code is beautiful and simple and it
works.  And adding Scriptaculous effects or tools becomes even easier.

Maybe file size is a concern?  Prototype serves at 12KB with gzip
compression and caches.

I'm not trying to start some major political debate, I'm just curious
what everyone's thoughts are on this matter.  If it's been discussed
before, link me, please.  :-)

Sincerely,

Ryan Scheuermann

--
----
Concept 64, Inc. | Phone: 610.349.0703 | Web: www.concept64.com

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Theodor Ramisch
Hi,
> I'm not trying to start some major political debate, I'm just curious
> what everyone's thoughts are on this matter.  If it's been discussed
> before, link me, please.  :-)

I mentioned this some months ago, see
http://comox.textdrive.com/pipermail/wp-hackers/2005-November/thread.html#3311
It wasn't really discussed, but one answer was that WordPress avoids
the use of public libraries due to security reasons.

Theodor
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Rob Miller-4
In reply to this post by Ryan Scheuermann
Definitely agree. I've wanted to use Scriptaculous in a number of
plugins, but it seems a bit wasteful (in terms of space and bandwidth)
to distribute it separately with each of them when it could so easily
(and benficially!) be centralised -and used - in the core code.

--
Rob Miller
http://robm.me.uk/ | http://kantian.co.uk/

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

David House
In reply to this post by Theodor Ramisch
On 23/04/06, Theodor Ramisch <[hidden email]> wrote:
> I mentioned this some months ago, see
> http://comox.textdrive.com/pipermail/wp-hackers/2005-November/thread.html#3311
> It wasn't really discussed, but one answer was that WordPress avoids
> the use of public libraries due to security reasons.

I wouldn't say that. At the moment we use:

* IXR (xmlrpc interface)
* Snoopy (remote URL fetcher)
* Magpie (RSS parser)
* Gettext (i10n)
* DBX (fancy moving boxes in admin)
* tx_sack (ajax)
* tinyMCE (wysiwyg)
* KSES (filtering dangerous tags in posts)
* ezSQL (DB interaction)

That's a fair share of external libraries, and I've probably missed some.

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Andy Skelton
In reply to this post by Ryan Scheuermann
On 4/23/06, Ryan Scheuermann <[hidden email]> wrote:
> Personally, I recommend Prototype.  http://prototype.conio.net/  It's
> being used by the Widgets plugin and all the major applications running
> Ruby on Rails (see any 37 Signals product), and I don't think it's
> support is going to go away anytime soon.  And if you've ever seen
> anything written using it, the JS code is beautiful and simple and it
> works.

Why thank you! You're really too kind ;-)

Yeah, I'd love to start using Prototype and Scriptaculous in more
places in the admin and even have it available to themes. Getting rid
of Sack would be great.

We ought to have a set of core PHP functions to handle javascript
includes. Sort of like a wrapper for
add_action(is_admin()?'admin_head':'wp_head', $callback) where
$callback cannot be registered twice and known dependencies can be
handled (e.g. if Scriptaculous, include Prototype).

Another possibility is to write a gzip compressor that concatenates
all of the requested js libraries and compresses them. This would
reduce bandwidth in most cases.
script src="wp-includes/js/wp_js.php?prototype+scriptaculous"

Caveat: each combination of libraries would be downloaded and cached
without regard for the desired script already having been downloaded
in another combination.

Anybody interested in doing this for 2.1?

Andy
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Robert Deaton
On 4/23/06, Andy Skelton <[hidden email]> wrote:
> Yeah, I'd love to start using Prototype and Scriptaculous in more
> places in the admin and even have it available to themes. Getting rid
> of Sack would be great.

+1 on prototype and the removal of sack

I'm iffy on the thought of Scriptaculous. Scriptaculous is relatively
huge, and after the addition of TinyMCE I'm not sure if we should be
willing to add another huge chunk of javascript. I personally would
like to see something like moo.fx, which is beautiful and tiny (3KB)

> We ought to have a set of core PHP functions to handle javascript
> includes. Sort of like a wrapper for
> add_action(is_admin()?'admin_head':'wp_head', $callback) where
> $callback cannot be registered twice and known dependencies can be
> handled (e.g. if Scriptaculous, include Prototype).

+1

> Another possibility is to write a gzip compressor that concatenates
> all of the requested js libraries and compresses them. This would
> reduce bandwidth in most cases.
> script src="wp-includes/js/wp_js.php?prototype+scriptaculous"

-1, because of the following caveat

> Caveat: each combination of libraries would be downloaded and cached
> without regard for the desired script already having been downloaded
> in another combination.

--
--Robert Deaton
http://somethingunpredictable.com

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Andy Skelton
On 4/23/06, Robert Deaton <[hidden email]> wrote:
> I'm iffy on the thought of Scriptaculous. Scriptaculous is relatively
> huge, and after the addition of TinyMCE I'm not sure if we should be
> willing to add another huge chunk of javascript. I personally would
> like to see something like moo.fx, which is beautiful and tiny (3KB)

Scriptaculous isn't going to be necessary. When Brothercake's dbx [1]
is updated with the things I need for Widgets, I'll probably stop
using Scriptaculous. In combination with your suggestion of moo.fx [2]
I think we'd have enough features to drop Scriptaculous.

I actually had a blind guy who blogs about braille ask me how to move
the widgets without a mouse. Brothercake's scripts are 100% keyboard
accessible.

Andy

[1] http://www.brothercake.com/site/resources/scripts/dbx/
[2] http://moofx.mad4milk.net/
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Viper007Bond
Yeah, I was going to suggest moo.fx as well. It's WAY lighter and has
all the basic stuff you need without the bloat of stuff you don't.

However, if we do go with a larger package, I'd like to see it split up
into smaller files. That way a plugin / admin page / whatever can just
call the bits it needs (say AJAX or collapse/expand) rather than the
whole, huge ass script.

-Viper

Andy Skelton wrote:

> On 4/23/06, Robert Deaton <[hidden email]> wrote:
>> I'm iffy on the thought of Scriptaculous. Scriptaculous is relatively
>> huge, and after the addition of TinyMCE I'm not sure if we should be
>> willing to add another huge chunk of javascript. I personally would
>> like to see something like moo.fx, which is beautiful and tiny (3KB)
>
> Scriptaculous isn't going to be necessary. When Brothercake's dbx [1]
> is updated with the things I need for Widgets, I'll probably stop
> using Scriptaculous. In combination with your suggestion of moo.fx [2]
> I think we'd have enough features to drop Scriptaculous.
>
> I actually had a blind guy who blogs about braille ask me how to move
> the widgets without a mouse. Brothercake's scripts are 100% keyboard
> accessible.
>
> Andy
>
> [1] http://www.brothercake.com/site/resources/scripts/dbx/
> [2] http://moofx.mad4milk.net/
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Andrew Krespanis
In reply to this post by Andy Skelton
+1 Prototype in core
+1 moo.fx in core

On 4/24/06, Andy Skelton <[hidden email]> wrote:
> I actually had a blind guy who blogs about braille ask me how to move
> the widgets without a mouse. Brothercake's scripts are 100% keyboard
> accessible.

James(brothercake) works _extremely_ hard on the accessibility of his
javascript. I would very much like to see the example set by his DBX
script followed by any other JS powered features to be included in WP
core. I have access to a wide array of assistive technologies  and am
happy to help with testing, but it is more important that developers
who are writing these new JS features make themselves aware of the
issues faced by dissabled users _before_ implementing said features :)

Andrew.

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Andy Skelton
On 4/23/06, Andrew Krespanis <[hidden email]> wrote:
> [...] it is more important that developers
> who are writing these new JS features make themselves aware of the
> issues faced by dissabled users _before_ implementing said features :)

The issues were fully known when the Widgets plugin was developed and
released. There did not exist any keyboard-accessible libraries that
did what I required, so I went ahead with something that works for
most people. I blogged the feature request, emailed James and even
spoke with him in person about the need. When he has released a stable
version that does what we require, it will replace Scriptaculous in
the Widgets plugin.

The blind user I mentioned does have a working interface for moving
and adjusting his widgets: he can email me. It's slower but it works
and he's happy with it.

Not that I need to defend Widgets from anyone, but I want to convey
that the lack of a 100% accessible tool should not be used to stop
development.

Andy
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Rob Miller-4
In reply to this post by Viper007Bond
Viper007Bond wrote:

> Yeah, I was going to suggest moo.fx as well. It's WAY lighter and has
> all the basic stuff you need without the bloat of stuff you don't.
>
> However, if we do go with a larger package, I'd like to see it split
> up into smaller files. That way a plugin / admin page / whatever can
> just call the bits it needs (say AJAX or collapse/expand) rather than
> the whole, huge ass script.
>
> -Viper
> _________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>

Would it not be better to always include all of the JS? That way you
don't have to work out which elements to include for your particular
plugin/script, you don't end up including things twice, and there's no
tangible increase in download times/bandwidth usage because of the caching?

--
Rob Miller
http://robm.me.uk/ | http://kantian.co.uk/

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Owen Winkler
Rob wrote:
> Would it not be better to always include all of the JS? That way you
> don't have to work out which elements to include for your particular
> plugin/script, you don't end up including things twice, and there's no
> tangible increase in download times/bandwidth usage because of the caching?

Yeah, I was wondering about that.  Why are we trying to out-think
browser caching?  Using slim libraries seems like a good idea, and
including only what you need on a per-page basis seems like a good idea,
but wasting (even minimal) server resources to rebuild different
combinations of javascript that will likely each be cached separately...
  Wha?

Owen


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Ryan Scheuermann
Owen Winkler wrote:

> Rob wrote:
>> Would it not be better to always include all of the JS? That way you
>> don't have to work out which elements to include for your particular
>> plugin/script, you don't end up including things twice, and there's
>> no tangible increase in download times/bandwidth usage because of the
>> caching?
>
> Yeah, I was wondering about that.  Why are we trying to out-think
> browser caching?  Using slim libraries seems like a good idea, and
> including only what you need on a per-page basis seems like a good
> idea, but wasting (even minimal) server resources to rebuild different
> combinations of javascript that will likely each be cached
> separately...  Wha?
>
> Owen
>
Not only that, it makes code maintenance a hell of a lot easier.

----
Concept 64, Inc. | Phone: 610.349.0703 | Web: www.concept64.com

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Michael D Adams
In reply to this post by Ryan Scheuermann
On Apr 23, 2006, at 6:32 AM, Ryan Scheuermann wrote:
> No offense to whomever wrote all this wonderful AJAX and list  
> management code, but I fear the maintainability and extensibility  
> of all this is going to become a problem in future releases.
None taken.  I'm not sure about your maintainability concern, though.

> Personally, I recommend Prototype.  http://prototype.conio.net/
Prototype is very nice.  It wasn't quite up to snuff when the first  
grain of ajax went into WP, and sack was lean, easy as heck to use  
and written by a "member of the WP community" (however one defines  
that).  Boom.  Instant category addition.

As the listMan stuff developed,  sack's limitations started cropping  
up.  That's why list-manipulation-js.php defines the WPAjax "class".  
It's a half-baked attempt to do some generic error passing and  
response validation, and it's a convenient place to keep any bits  
needed for consistency.

listMan is not brilliant code.  It's pretty ugly in places,  
actually.  But it gets the job done.  All of the JS files that use it  
are < 30 lines of code (most are ~5) and could be made even better  
with a tweak or two here and there.  Also (other than the recoloring  
of alternating rows) it all seems pretty fast (I don't have anything  
even close to a set of benchmarks).

If we decide to use prototype, I'd be all for that; it's popular,  
well maintained and it works.  Someone else can do the listMan  
rewrite (or replacement), though.  It should have another set of eyes  
look at it anyway.

Michael
--mdawaffe
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Michael D Adams
In reply to this post by Andy Skelton
On Apr 23, 2006, at 1:55 PM, Andy Skelton wrote:
> We ought to have a set of core PHP functions to handle javascript
> includes. Sort of like a wrapper for
> add_action(is_admin()?'admin_head':'wp_head', $callback) where
> $callback cannot be registered twice and known dependencies can be
> handled (e.g. if Scriptaculous, include Prototype).
To jump on the bandwagon: +1.  That is a very nice idea.

> Another possibility is to write a gzip compressor that concatenates
> all of the requested js libraries and compresses them. This would
> reduce bandwidth in most cases.
> script src="wp-includes/js/wp_js.php?prototype+scriptaculous"
To continue to do so (for the same reasons others have better put): -1

Michael
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Matt Mullenweg
In reply to this post by Michael D Adams
Michael D Adams wrote:
> listMan is not brilliant code.  It's pretty ugly in places, actually.  
> But it gets the job done.  All of the JS files that use it are < 30
> lines of code (most are ~5) and could be made even better with a tweak
> or two here and there.  Also (other than the recoloring of alternating
> rows) it all seems pretty fast (I don't have anything even close to a
> set of benchmarks).

I do like how light it is. Functionality wise, it works great too.

> If we decide to use prototype, I'd be all for that; it's popular, well
> maintained and it works.  Someone else can do the listMan rewrite (or
> replacement), though.  It should have another set of eyes look at it
> anyway.

In addition to prototype, I think whoever takes ownership of this should
take a strong look at:

http://www.mochikit.com/
http://dojotoolkit.org/

In addition to the Prototype cousins already mentioned.

--
Matt Mullenweg
  http://photomatt.net | http://wordpress.org
http://automattic.com | http://akismet.com
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Ryan Scheuermann
Matt Mullenweg wrote:
> In addition to prototype, I think whoever takes ownership of this
> should take a strong look at:
>
> http://www.mochikit.com/
> http://dojotoolkit.org/
>
> In addition to the Prototype cousins already mentioned.
>
I've read a few articles comparing Prototype with Dojo.  Based on the
articles, Dojo seems a bit too new and under-tested.  As of this email,
I couldn't even get to the Dojo Wiki - which is not a result of the JS
library of course, but does say something about Dojo in general.  When I
looked at their Wiki previously (which utilizes Dojo) it seemed to have
more than a few quirks left to work out.

Word on the street seems to think it is over-designed while Prototype
was built from the concerns of real-world apps (Basecamp and now
Fluxiom) and tightly coupled with Ruby on Rails.

A friend of mine was just at The Java Server Side Symposium in March,
and although there didn't seem to be any talk about Mochikit, the
general consensus comparing Dojo and Prototype was that Prototype is
easier to use, more popular, and more lightweight.  But Dojo seemed to
be marketing themselves well.  :-)

Dojo's AJAX package is 208KB uncompressed while Prototype weighs in at
54KB.  But those may not include the same functionality; I had a hard
time determining which Dojo package matched Prototype exactly.  The Dojo
AJAX package may be comparable to Prototype w/ the Scriptaculous effects
libary (which is still over 100KB less than Dojo).  And Prototype w/
moo.fx is even less.

Documentation wise, Dojo is probably better (when you can get to the
Wiki) as Prototype's documentation is the source.  Though when browsing
the source, it's not hard to feel at home with it once you understand
the concepts.  And there are more third-party articles everyday on
"Intro to Prototype" and even more examples.  "Intro to Dojo" articles
are hard to come by.  Scriptaculous's Wiki also provides a lot of
documentation on Prototype as well.

I've seen Prototype w/ either Scriptaculous, moo.fx, and/or Behaviour on
small to medium-size sites and apps repeatedly, and I'm yet to come
across Dojo being used even once (but I may be hanging out in the wrong
circles for it).  For huge apps, Dojo may be more robust and modular,
but for WP and WP-driven sites, I can't imagine it's bulk or modularity
would be necessary.

So, as my preliminary opinion (I'm open to persuasion), I'd say
Prototype over Dojo, and I haven't investigated Mochikit (just heard of
it now myself).  Not what Matt calls a strong look, just my two cents
thus far.  I'm willing to contribute to this endeavor when a solid plan
is formulated.

Ryan Scheuermann
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: AJAX / JS libraries

Stewart Ugelow
In reply to this post by Matt Mullenweg
On 4/26/06, Matt Mullenweg <[hidden email]> wrote:

> In addition to prototype, I think whoever takes ownership of this should
> take a strong look at:
>
> http://www.mochikit.com/
> http://dojotoolkit.org/

Jon Aquino of Ning blogged about Prototype vs. Dojo last week:

http://jonaquino.blogspot.com/2006/04/comparison-of-dojo-and-prototype.html

--Stewart

--

Stewart Ugelow
www.ugelow.com
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers