websauna.system.core.render module¶
Rendering helpers.
-
class
websauna.system.core.render.
OnDemandResourceRenderer
[source]¶ Bases:
object
A JS and CSS resource registry which helps to allow widgets and such add JS and CSS files dynamically on the page.
Usually instance of this class is available as
request.on_demand_resource_renderer
.The best practice is to place all JavaScript files before the closing
</body>
tag, so that they do not block the the page rendering and decrease the page response time. However, out there exist a lot of badly written JavaScript code which does not honour this - they have<script>
tags in the middle of<body>
and even worse assume you have loaded dependencies, like jQuery, in the<head>
. Namely, Deform 2 form library does this.BodyRelocatableResourceRegistry
contains the logic to determine if<script>
tags should go to the end of the page (preferred) or to<head>
(in case some javascript makes assumptions of this). If any widget requires resources assume JS must go to head.See also :py:attr`deform.widget.default_resources` which includes the list of default resources activated for any form on the page.
More information
-
get_resources
(kind)[source]¶ Get list of resource URLs to render.
- Parameters
kind – “js” or “css”
- Return type
-