7

I have a simple app, using only a couple of packages

library(shiny)
library(tableHTML)
library(shinyWidgets)
library(shinyFeedback)
library(lubridate)

Overall it is fast once loaded, but on a new session window it takes 3-4s.

When I analyse it on https://developers.google.com/speed/pagespeed/insights/ this is the main issue

Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles. Learn more.


URL
Transfer Size
Potential Savings
…shared/shiny.min.css()
1.9 KiB
180 ms
…css/shinyfeedback.css()
0.6 KiB
330 ms
…css/all.min.css()
12.7 KiB
630 ms
…css/v4-shims.min.css()
4.4 KiB
480 ms
…css/toastr.min.css()
3.1 KiB
330 ms
…shinyWidgets/shinyWidgets.min.css()
1.0 KiB
330 ms
…bootstrap-switch-3.3.4/bootstrap-switch.min.css()
1.4 KiB
180 ms
…css/bootstrap.min.css()
19.6 KiB
780 ms
…css/bootstrap-accessibility.min.css()
0.8 KiB
180 ms
…__assets__/shiny-server.css()
1.3 KiB
180 ms
…shared/jquery.min.js()
30.5 KiB
1,080 ms
…shared/shiny.min.js()
25.7 KiB
930 ms
…js/shinyfeedback.js()
2.9 KiB
180 ms
…js/toastr.min.js()
2.3 KiB
180 ms
…js/shinytoastr.js()
0.6 KiB
180 ms
…shinyWidgets/shinyWidgets-bindings.min.js()
6.1 KiB
330 ms
…bootstrap-switch-3.3.4/bootstrap-switch.min.js()
3.8 KiB
180 ms
…js/bootstrap.min.js()
11.0 KiB
480 ms
…js/bootstrap-accessibility.min.js()
4.3 KiB
330 ms
…__assets__/sockjs-0.3.4.min.js()
11.4 KiB
480 ms
…__assets__/shiny-server-client.min.js()
18.6 KiB
480 ms

From what I read on JS websites, the answer is to make this all async. Is there an option with R shiny?

see sample app


library(shiny)
library(tableHTML)
library(shinyWidgets)
library(shinyFeedback)
library(lubridate)


ui <- fluidPage(
              div(id = 'mainp',
                  
                  div(style = 'margin-bottom:30px;margin-top:10px; text-align:center',
                      span('My app', style = 'font-size:24px'),
                      tableHTML_output('mytable')
                      )
              )
)

server <- function(input, output, session) {
  
  output$mytable <- render_tableHTML({
    tableHTML(head(mtcars))
  })
  
}

shinyApp(ui = ui, server = server)
Arkadi w
  • 129
  • 22
  • Provide more code please (some minimal pieces to reproduce). Currently I have 2 ideas what can help - server rendering or async loading and rendering with loader. – A Ralkov Mar 14 '21 at 05:50
  • See above. Very simple app. – Arkadi w Mar 15 '21 at 06:05
  • I see, sorry for misunderstanding. Unfortunately I don't know R, but I've read some basic conceptions.. Firstly, R is single-threaded and async features are in libraries. So, default `library` is sync and seems to be very complex to make it async. But secondly, since async operations are available, it's possible to write your own async `library` version. – A Ralkov Mar 15 '21 at 09:55
  • Is this likely? By the time the app is up and running the `library` calls have finihsed long ago. – Sirius Mar 19 '21 at 13:12
  • 1
    Note - on the Insights results page, its the _Mobile_ that gets the poor grade, if you click _Desktop_ I get 99, which shouldnt' require any action. Do you mean to serve your shiny app to _Mobile_ clients? – Sirius Mar 19 '21 at 13:24

0 Answers0