Is there a way to move all inline JavaScript and CSS in HTML format to external files? #11736
Replies: 1 comment
-
There is no built it configuration that will allow you to do that. Some of the inline CSS are coming from template, so for this one you could create your own template and externalize the CSS. Example with Pandoc's style quarto-cli/src/resources/formats/html/pandoc/styles.html Lines 190 to 200 in 3f492cc coming from styles.html which is inserted in HTML templatequarto-cli/src/resources/formats/html/pandoc/template.html Lines 8 to 11 in 3f492cc This is how Pandoc's is doing it and we did no change that Other content are inserted inline directly by Quarto itself, like the search options that we do add as included text quarto-cli/src/project/types/website/website-search.ts Lines 613 to 615 in 3f492cc using include logic for HTML https://quarto.org/docs/output-formats/html-basics.html#includes So this would be an enhancement request to make all those content in external file, and also would require to maintain this comparing to Pandoc's difference. Hope it helps understand.
Regarding,
Some of the content you see is indeed added only when some features are not opt-out. |
Beta Was this translation helpful? Give feedback.
-
Description
Is there a way to have all JavaScript and CSS rendered into external files instead of in the body of the HTML document?
I made a very simple and basic site and there is a lot of non HTML stuff inline in the document. This is less efficient and also makes it harder to implement CSP, etc. There are many other library files included, so I am not sure why some stuff is inline?
e.g., in the rendered
index.html
I see:In the
<head />
:and
and then quite a bit more at the end of the file
This seems to be a lot to include by default, some of it seems to only be conditionally needed. I would like to reduce bloat where possible, but also ideally my HTML page just links/imports things rather then inline. If its well organized I could do post processing to remove the unnecessary libraries.
I saw some things mentioning:
but these do not seem to do anything. I also see you can disable some features, but it would still seem to be better if these were not online even if you wanted them.
e.g, I have in
_quarto.yml
and then a simple
index.qmd
Beta Was this translation helpful? Give feedback.
All reactions