Skip to content

How do I include a .js script across a website without format-resources? #10654

Answered by cderv
andrewpbray asked this question in Q&A
Discussion options

You must be logged in to vote

Oh I know ! 🤦

include-in-header has text and file option. The file option is just a convenient way to do text by letting Quarto read from a file.

This means the content is expected to be HTML. Here you are passing directly the .js so it will read your JS file and put the content inside the HTML header, and somehow this gets inserted after body. Probably because the content is not valid HTML anyway.

Dealing with path resolution for extension is not simple. Quarto does the right thing when file are passed in extension. But it does not catch and modify a path in text like <script src="mysidebar.js"></script>.

So it would do the right thing for something like this

      include-in-header:
   …

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@andrewpbray
Comment options

@cderv
Comment options

@mcanouil
Comment options

@cderv
Comment options

Answer selected by andrewpbray
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
extensions relates to Quarto extensions mechanism html Issues with HTML and related web technology (html/css/scss/js)
3 participants