I have a script that creates nested html output (using flexdashboard) files and each file is ~ 8MB. I think it should be possible to reduce the file size by storing the dependencies/formatting in a separate folder but I am not succeeding. I am specifying the following inside the rmarkdown::render call but I'm not seeing the "lib" folder once the script runs. Is there another way to reduce the output file size?
Yes, I tried that. Though the script runs, the "lib" folder is not populated (even when I pre-create it in the working directory). I'm not very familiar with js/HTML, what types of files should I expect in the "lib" folder?
Ah, maybe the dependencies need to be put into the "lib" folder first and then when .Rmd file is rendered it reads the dependencies in from the "lib" folder and so the resulting html files can be smaller in size? I don't really know how html rendering/dependencies work so that's contributing to the issue here.
So sorry for the delay. I am trying to reduce the size of the html output files (right now my files are ~ 8mb each). I thought that if I put the dependencies in a separate "lib" folder, the actual html files would be smaller? The example you provide above works fine and does generate the "lib" folder. So I'll continue troubleshooting my script to see if it's the render call that's not working or if something else is preventing the "lib" folder from populating with all the dependencies.
Circling back to this: I did get it to work eventually (though it only seems to work when the logo/theme/orientation are defined in YAML, not through the rmarkdown::render call). I now have a separate "lib" folder with all the dependencies and the resulting HTML file is 0.5 mg instead of 8mb, which is a win.
However, for my purposes it is inconvenient to have to have a local "lib" folder for every output file (it's complex nested structure). Is it possible to store dependencies externally?
For example, in the resulting html file, there's a call:
Those call are inserted for the them by the default template. It is part of html_document format.
I think if you want to really customize the output with such things, you would need to not use a theme built in rmarkdown, or even change the default html template provided by rmarkdown tp use your own. For the former, that would mean setting theme = NULL to pass yourself the CSS you want, and the latter use template to provide a pandoc template you would create with the call you want inside.
One other follow up, if I may: does it matter that I am creating not just html_document format but flexdashboard pages? I have a sample call below (with output_options commented out), are you saying I could specify the theme to null and just update the css to have all the proper formatting? And the css would be specifying links to external dependencies? Thank you again so much for your help.
(by the way, for defining output_options as self_contained = FALSE to work, I couldn't call flexdashboard from the render function, and instead had to define it in the YAML in the Rmd file. Not sure if that's a feature or a bug).