Repository navigation
Description
This follows #1912 fixed by #1942.
Following the merge of the PR, @gadenbuie have seen issues in learnr possibly related to this:
- Adjust tutorial template for correct ordering of dependency loading learnr#499
- Time taken to load JS and CSS files learnr#502
Putting his comment here too: #1942 (comment)
Adding the additional dependencies at the end of
<head>feels like the right thing to do but, unfortunately, it breaks previous behavior. Before this change the served document structure was (essentially):shiny boilerplate: |- head |- body |- full prerendered document |- head |- bodyso the dependencies added by shiny were in the first
<head>tag and the document's dependencies appeared in the second<head>tag. When reconciled by the browser, this ends up being the same asbrowser DOM |- head |- shiny dependencies |- prerendered doc dependenciesIn learnr, for example, this creates a situation where the scripts and dependencies in the tutorial's pandoc template appear before the tutorial dependencies provided by learnr.
This may be the correct behavior and we can adjust in learnr, but I suspect there are other templates that take advantage of the implicit ordering of dependencies in the previous behavior.
Currently, format like learnr assumes shiny dependencies is loaded before documents dependencies. This is the previous behavior. Maybe we should stick with that.
This issue is to track discussion in which order the dependencies should be added. Currently, using shiny templating when the page is render, the dependencies are added at the end of the head
rmarkdown/R/shiny_prerendered.R
Lines 163 to 169 in c0b8584
| # add placeholder for additional dependencies at the end of the <head> element | |
| # using a template expansion expected by shiny (usually done in shiny:::renderPage) | |
| sub('</head>', | |
| paste0('\n', htmltools::htmlTemplate(text_ = "{{ headContent() }}"), '\n</head>'), | |
| html_with_deps, | |
| fixed = TRUE, | |
| useBytes = TRUE) |
Should it be at the top of the head ? Or is it more complex than that to correctly handle document head without shiny header ?
Activity
cderv commentedon Mar 1, 2021
Some takes on what we discussed:
To insert the content in a correct place in the header:
<!-- HEAD_CONTENT -->special comment thatshiny::renderPageexpects.Going for the latter would allow more control by template producer. We could make this conditional in the pandoc template using a pandoc variable that would be activated when render happens for shiny_prerendered.
Thanks @schloerke and @gadenbuie for the discussion and all the inputs!
Allow to add specific shiny-prerendered parts in HTML template (#2064)
github-actions commentedon Sep 7, 2021
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.