sphinx-needs icon indicating copy to clipboard operation
sphinx-needs copied to clipboard

Add sphinx-needs specific .css and .js only on html pages where necessary

Open StephanKuempel opened this issue 3 years ago • 0 comments

Currently, the sphinx-needs specific .css and .js files (datatables.min.css/js, common.css, layouts.css , etc.) are added to every .html file globally, disregarding whether needed or not. For performance reasons (especially the big datatables.min.js), this should be changed to a selective additon only to the necessary htmls.

This can be realized by using the html-page-context event, which is called by the builder after each build of a html page. The css/js can be added via context['css_files'].append("_static/sphinx-needs/....css"), context['script_files'].append("_static/sphinx-needs/....js") each time.

@danwos I already tested this quickly and think it would work.

This is also loosly related to #455

StephanKuempel avatar Jan 10 '22 09:01 StephanKuempel