daattali/shinyjs

Possible to move inline scripts to a .js file for easier CSP implementations?

Open

#274 aberto em 9 de out. de 2024

Ver no GitHub
 (6 comments) (0 reactions) (0 assignees)R (104 forks)batch import
enhancementhelp wanted

Métricas do repositório

Stars
 (521 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Not sure if this is even possible, but I thought it is worth to ask.

When calling shinyjs::useShinyjs, many functions are injected inline in the UI. This is a problem when implementing a strict CSP for a Shiny web application, since inline scripts are blocked by default. Would it be possible that these functions are loaded by calling a script file in the package inst folder instead of injecting them inline? Maybe using a variant of the inject.js script that was previously present in the package, to create the needed calls dynamically?

May be related to #101

On a sidenote: I suspect that the documentation on how to include shinyjs using a HTML template is outdated, since the function inject.js is not included in the package anymore: https://github.com/daattali/shinyjs/blob/0648faa0dc985a5be55bbc745fe042056a0ecfc3/vignettes/shinyjs-usage.Rmd#L167

Guia do colaborador