There are thousands of JavaScript at the beginning of the .html file when outputted using RMarkdown

We used RMarkdown for static .html pages, but there is javascript at the beginning of each document consisting of thousands of lines when we checked the source codes (line 17 to line 27 in the first figure), even for a simple "hello world" webpage. Is there any way to eliminate this? enter image description here

In the meantime, I also used another computer to generate the .html file with the same code. It showed the difference. I pasted 2 parts of the scripts here. enter image description here enter image description here

Are the javascript in these two files have the same function? And why they are so different? I guess they are the same and the first version is the compressed version of the expanded one, right?

Thank you so much for your help!!!

The javascript included into your HTML result with rmarkdown will depend on the output format used and also the content of the document. Any feature used that requires JS or CSS will create a line in the header of the document.

With a default html_document, you will have some JS and CSS because there is some feature like table of content, boostrap theming, code folding, tabset, ... This will lead to some html dependencies being including in the doc.

The doc of html_document can give you some hints on this

You can also provide a custom template if you want to have full control over what is produced, but you need to learn about Pandoc, and some features of rmarkdown or R packages may not work unless you know how to tweak.

Hope it helps

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.