I would like to suggest an optional method registering scripts and their dependencies within the Drupal core. The concept would be to provide for .info like files for scripts that would include their dependencies, including version/sub-version/etc. Then a librarian could be used to allow the peaceful co-existence of multiple versions of plug-in libraries within the same site.

Without in-depth analysis, my initial thought would be to utilize some form of token, tied to class or ID tags, that would indicate the client-side linkage to a specific javascript. This javascript in turn would be registered with its dependencies, and those dependent scripts with their dependencies, etc. For example, if I deployed a script that was dependent on Dialog from jQueryUI 1.8.9, I would register Dialog 1.8.9 in my info file. Dialog likewise would register core, widget, mouse, position, etc. Then position would register jQuery 1.4. Now, if the current page being displayed utilized elements that required say jQuery 1.2 (such as 6.x AHAH) in addition to my custom scripts, core would generate an error on load, and load neither jQuery core, nor any scripts dependent on JQuery core. On the other hand, if the current page *only* utilized AHAH, then jQuery 1.2 would be included. Likewise, if it only relied on my custom script, then jQuery 1.4 would be deployed.

This would allow developers to reconcile these issues without impacting our ability to utilize enhancements in jQuery, and its related plugins.

For performance reasons, I would assume that these dependencies and script inclusions would be cached, much like the menu & theme systems are currently, requiring the cache be cleared when new scripts were added to a given page.

I apologize if this is a re-hash of a previous issue, or is currently technically infeasible in either 6.x or 7.x. In either case, I would appreciate it if you could point me to the appropriate documentation.

Best Regards,
Tim Foley

Comments

rfay’s picture

Version: 7.0 » 8.x-dev
Component: ajax system » javascript

New changes go into 8.x.

nod_’s picture

Status: Active » Postponed

If we're doing our homework on #1033392: Script loader support in core (LABjs etc.), this use case will be easy to support.

nod_’s picture

Category: feature » support
nod_’s picture

Status: Postponed » Closed (works as designed)
Issue tags: -jQuery, -ahah, -Ajax, -client-side scripting

Some of this issue is addressed by the generalized library usage.

I don't feel like supporting several version of the same lib is something we want in core.