Description
Description:
The render_assets function in Jinjax is currently sorting JavaScript and CSS files alphabetically by their names before rendering them. This behavior introduces issues when the loading order of assets is critical — for example, when a script depends on another being loaded first (e.g., jQuery before a plugin), or when CSS rules are intended to override earlier ones.
Expected behavior:
Assets should be rendered in the order they are declared. This ensures that dependencies are respected and styles/scripts behave as intended.
Actual behavior:
Assets are being automatically sorted by filename, breaking intended load order.
Suggested fix:
Remove automatic sorting in render_assets and preserve the user-defined order.
To let the user in control, it could be an argument when calling catalog.render_assets(sorting=False)
.
Environment:
Jinjax version: 0.57
Python version: 3.12
Here a screen capture of the difference in rendering...