def html_assets(cls, core=True, extras=True, backends=None, script=False):
        """
        Returns JS and CSS and for embedding of widgets.
        """
        if backends is None:
            backends = [cls.backend] if cls.backend else []

        # Get all the widgets and find the set of required js widget files
        widgets = [wdgt for r in [Renderer]+Renderer.__subclasses__()
                   for wdgt in r.widgets.values()]
        css = list({wdgt.css for wdgt in widgets})
        basejs = list({wdgt.basejs for wdgt in widgets})
        extensionjs = list({wdgt.extensionjs for wdgt in widgets})

        # Join all the js widget code into one string
        path = os.path.dirname(os.path.abspath(__file__))

        def open_and_read(path, f):
            with open(find_file(path, f), 'r') as f:
                txt = f.read()
            return txt

        widgetjs = '\n'.join(open_and_read(path, f)
                             for f in basejs + extensionjs if f is not None)
        widgetcss = '\n'.join(open_and_read(path, f)
                              for f in css if f is not None)

        dependencies = {}
        if core:
            dependencies.update(cls.core_dependencies)
        if extras:
            dependencies.update(cls.extra_dependencies)
        for backend in backends:
            dependencies[backend] = Store.renderers[backend].backend_dependencies

        js_html, css_html = '', ''
        for _, dep in sorted(dependencies.items(), key=lambda x: x[0]):
            js_data = dep.get('js', [])
            if isinstance(js_data, tuple):
                for js in js_data:
                    if script:
                        js_html += js
                    else:
                        js_html += '\n<script type="text/javascript">%s</script>' % js
            elif not script:
                for js in js_data:
                    js_html += '\n<script src="%s" type="text/javascript"></script>' % js
            css_data = dep.get('css', [])
            if isinstance(js_data, tuple):
                for css in css_data:
                    css_html += '\n<style>%s</style>' % css
            else:
                for css in css_data:
                    css_html += '\n<link rel="stylesheet" href="%s">' % css
        if script:
            js_html += widgetjs
        else:
            js_html += '\n<script type="text/javascript">%s</script>' % widgetjs
        css_html += '\n<style>%s</style>' % widgetcss

        comm_js = cls.comm_manager.js_manager
        if script:
            js_html += comm_js
        else:
            js_html += '\n<script type="text/javascript">%s</script>' % comm_js

        return unicode(js_html), unicode(css_html)
Returns JS and CSS and for embedding of widgets.