Quarto - OJS fails to render but previews


I am trying to include Observable chunks in my Quarto document.

I am following the RStudio Quarto Observable book and some other questions in this forum, but I encountered a weird behaviour.

For a reprex, this is the document I am trying to render. You need the palmerpenguins package to reproduce.

ojs_define(data = palmerpenguins::penguins)

viewof bill_length_min = Inputs.range(
  [32, 50],
  {value: 35, step: 1, label: "Bill length (min):"}
viewof islands = Inputs.checkbox(
  ["Torgersen", "Biscoe", "Dream"],
  { value: ["Torgersen", "Biscoe"],
    label: "Islands:"

filtered = transpose(data).filter(function(penguin) {
  return bill_length_min < penguin.bill_length_mm &&

    {y: "count"},
    {x: "body_mass_g", fill: "species", thresholds: 20}
    facet: {
      data: filtered,
      x: "sex",
      y: "species",
      marginRight: 80
    marks: [

Now, if I run quarto render penguins.qmd in the terminal, the document renders without any interactive snippets (it just shows code chunks). If instead I run quarto preview penguins.qmd it displays as expected.

Other information:
I am running RStudio 2022.07.0+548 "Spotted Wakerobin" Release (34ea3031, 2022-07-06) for macOS, on a M1 Max MacbookPro running macOS Monterey v12.5.1.

Any help or pointer to resources would be greatly appreciated!

I believe this is expected. OJS is JS based, and opening a HTML file only in a browser is not like looking at an online webpage. Some resources may not load, or feature not work.

This is why you need quarto preview so that a local web server is started for you too look at your document.

Some discussion in

Right, I had missed that discussion and it makes sense now. I thought I couldn't expect chunks to display in the visual editor but I missed the other requirements.

In fact when I upload my quarto rendered page to a web server it displays as expected.


This topic was automatically closed 7 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.