'Saving HTMLWidget with links to HTML dependencies instead of embedding them

I save my ggplotly object using saveWidget() function. If I do it with selfcontained=TRUE option, all HTML dependencies (javascript libraries and CSS styles) are saved inside the HTML file making it very big. If I use selfcontained=FALSE, those dependencies are saved in separate _file folder, and linked from the HTML file:

<script src="testA_files/htmlwidgets-1.5.3/htmlwidgets.js"></script>
<script src="testA_files/plotly-binding-4.9.2.1/plotly.js"></script>
<script src="testA_files/typedarray-0.1/typedarray.min.js"></script>
<script src="testA_files/jquery-3.5.1/jquery.min.js"></script>
<link href="testA_files/crosstalk-1.1.1/css/crosstalk.css" rel="stylesheet" />
<script src="testA_files/crosstalk-1.1.1/js/crosstalk.min.js"></script>
<link href="testA_files/plotly-htmlwidgets-css-1.52.2/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="testA_files/plotly-main-1.52.2/plotly-latest.min.js"></script>

For jQuery, for example, I know I can use the code.jquery.com repository and replace my call with src="https://code.jquery.com/jquery-3.5.1.min.js". Is there similar public repositories for all other dependencies?



Solution 1:[1]

Of all the dependencies you list, plotly is probably the biggest. The latest plotly refers to this cdn:

https://cdn.plot.ly/plotly-basic-2.5.1.min.js

You can see this by look at the plots dependencies like so:

p <- ggplotly(p) %>% partial_bundle(local = FALSE)
p$dependencies

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fifthace