Build on an external library? jQuery?

nedjo's picture

Major question #1 as we improve our js implementation: can/should we build on one of the leading external JS/AJAX libraries?

The impressive jQuery library might be a prime candidate. jQuery author John Resig has generously indicated his openness to making jQuery available to Drupal through a GPL license, see his post http://jquery.com/discuss/2006-May/001448/ (and the full thread, http://jquery.com/discuss/2006-May/), provided some concerns and issues could be addressed.

Advantages:
* jQuery would meet most of our needs, covering existing drupal.js functionality and more.
* The library is compact and very well written.
* We don't need to do everything in house.
* There is an active development community. We get access to some of the cleanest code and brightest minds in js development.

Issues/disadvantages:
* License issues still need to be discussed more.
* Issues of relying on external libraries--updates, security fixes, etc.
* Potential conflicts with
* We get more than we absolutely need. The external library may have methods that we don't use.
* Reliance--jQuery "is designed to change the way that you write Javascript", and certainly succeeds. That means code we develop on this base won't be portable--it will be tied to jQuery.

Of course, we would still need to develop Drupal-specific methods, probably built on/extending the jQuery base.

From where I sit, the advantages sure look attractive--attractive enough to warrant us working through the issues.

What do others think?

Comments

Your last point, that we

kkaefer's picture

Your last point, that we rely on jQuery if we switch to it, isn't valid. If we build our own library, we do also need this library. The code won't be portable to prototype or jQuery, either. But apart from that, I actually like the idea of adopting jQuery, if the licence issue is resolved.

I don't think that jQuery updates will be a big problem. We just include the newest (tested) version with each release. That's it.

I have thought about this

kkaefer's picture

I have thought about this and I think that we need a solution to this issue in two or three weeks. Because I don't want to base my SoC project on an approach that gets abandoned several weeks or months later... And I guess Avi Mehta doesn't want that either...
So, if we make decisions, it would be wise (at least for us) to make them before the end of the month.

+1 to use an external

Frando's picture

+1 to use an external library.

Libraries like jQuery have improved a lot in the past year and are now quite sophisticated frameworks that can ease a lot of tasks.

IMO, we would waste quite a lot of time and effort if we wanted to rebuilt all of this good existing code.

I think the advantages you mentioned weight much higher than the disadvantages, as the latter are mostly easy-solvable:
* License issues still need to be discussed more.
the mailing list post you linked seems to be quite optimistic. Otherwise, there are other good javascript frameworks out there. I think we should do some more research on the different libraries in any case.

* Issues of relying on external libraries--updates, security fixes, etc.
I can't see a big difference between having a own library and having an external library here. If we would discover a critical security bug in our own library, we have to fix it and maybe release a new drupal version. If a bug is discovered in our external library, we do nearly the same (fix the bug or wait until it gets fixed and - if it's a really critical security issue - release a new drupal version).
* We get more than we absolutely need. The external library may have methods that we don't use.
True. However, I don't think that this is a big issue. Traffic caused by javascript libraries is nearly zero (as they usually get cached by the visitor's browser), and a few function declarations more have really a negligible influence on this. Contrib modules might even profit from functions that aren't use in core.

regards,
frando

Hi all.

ultraBoy's picture

Hi all.
After lots of thoughts about the topic, I decided that it's nothing bad to use external lib. And I vote for JQuery. JS/AJAX library, especially a good one is not a simple thing, actually! So what are the problems? Particulary, for JQuery:

  • "License" -- seems to be a solved problem

  • "Issues of relying on external libraries--updates, security fixes, etc. " -- Security can be fixed by the JQuery maintainer/community. And what are security problems with client-side library?

  • "Potential conflicts with" - with what??? If we drop/adapt current JS code and will take in account JQuery for future drupal JS developments, there will be no issues. And dropping/adapting will be necessary anyway if we will write own solid JS lib.

  • "We get more than we absolutely need. The external library may have methods that we don't use." -- But it's only 15kB!!!

  • "Reliance--jQuery "is designed to change the way that you write Javascript", and certainly succeeds. That means code we develop on this base won't be portable--it will be tied to jQuery." -- as it was already sad, we'll be tied anyway, with any library!

Any real disadvantages?

Javascript

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week