While developing "widgets" (objects, which - rendered - use some custom javascript files), I faced the need of creating kind of "included-scripts-manager" (to avoid double inclusion of same JS file when more than one widget is rendered for the view).
My first idea was to write custom template rendering Context which would provide EXTRA_SCRIPTS variable in the template. However I have no idea where should I collect the list of scripts during request processing? I think that's where I'd need singleton object.
Any suggestions?