Including JS/CSS in reusable widget library

Skip to first unread message

Thomas Güttler

Sep 30, 2014, 8:37:49 AM9/30/14
The way django handles static media works very well for js/css files which are included
in the library.

But if you want to build in external js/css files it gets ugly.

For example nice django-selectable widget. Has a long documentation on how to
include jquery-ui:

I came across this, because we use django-selectable in one project with success, but
it failed in an other. The reason was the missing jquery-ui js-files.

Ain't there a better solution for this?

Documentation like the above pages are good. But it is even better if there is
a common way how to handle this in the django world.


Thomas Güttler

Collin Anderson

Oct 1, 2014, 8:44:04 AM10/1/14
I usually use "assets" (class Media) for including cdn hosted libraries.

Thomas Güttler

Oct 2, 2014, 7:05:27 AM10/2/14
Am 01.10.2014 um 14:44 schrieb Collin Anderson:
> I usually use "assets" (class Media) for including cdn hosted libraries.

Example: how can a reusable widget library tell that it needs jquery-ui?

Up to now the only way I see is, that the reusable widget library includes jquery-ui
in its assets (static files via Media).

But if you use two or three reusable widget libraries on one page
each widgets loads its own version of jquery-ui.

Loading one js library several times is looking for trouble.

If you just reuse the widget library in a commercial closed source environment,
you can define fixed paths to libraries like jquery, jquery-ui, ...

But this does not work for reuse in the open source world.

I am missing something for a better reuse in the django world here.

Unfortunately I don't see a solution today. But maybe some else does.
Reply all
Reply to author
0 new messages