Hi I hope to start a discussion to find a consistent way to include javascript frameworks for custom widgets. It should prevent clashes between the javascript dependencies. We'll need to find a best practice that developers can follow to allow re-usable widgets to coexist site-by-side. I'm using jQuery for the following example, but this also applies to other javascript libraries.
Consider the following scenario: Developer A builds Widget `Foo` and developer B build Widget `Bar`. Both `Foo` and `Bar` require jQuery and the `superthingy` jQuery plugin. They both use the inner Media class on the widget to define media. Developer A defines the path to jquery as `http://ajax.googleapis.com/ ajax/libs/jquery/1.4.2/jquery.min.js` Developer B as `/media/barapp/js/libs/jquery.js` Similarly both developers use different paths for the `superthingy` plugin. Although media handling on forms does a great job of filtering out duplicates, it will still load the javascript twice if both widgets happen to be on the same page - breaking the widgets functionality. Approaches: [1] Have a project wide repository of frameworks and plugins (maybe a setting). Widgets load requirements by name and not by path. The project developer decides where to load the frameworks from. (e.g widgets would define: `settings.ASSETS['jquery']` and `settings.ASSETS['jquery.superthingy']` instead of hardcoded urls). [2] Don't include any shared libraries in the widget Media class at all. Tell the user in the docs to include the dependencies manually. (either on ModelAdmin, the Form or the Page) [3] Every widget loads it's own jQuery but hides it in it's own private namespace (like the `django.jQuery` namespace contrib.admin uses in django 1.2). Plugins are modified to load into that namespace... no clashes and allows multiple versions of jQuery. Potentially bad for memory usage and performance. What do you guys think? What approach would you prefer? Other ideas? -- Stefan -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.