Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve Framework7 and shinyMobile assets (CSS and JS) in CDN #189

Open
Esturban opened this issue Apr 27, 2021 · 3 comments
Open

Serve Framework7 and shinyMobile assets (CSS and JS) in CDN #189

Esturban opened this issue Apr 27, 2021 · 3 comments
Labels
enhancement New feature or request Framework7 This issue comes from the original template help wanted Extra attention is needed

Comments

@Esturban
Copy link

Hello,

I first want to start off by saying that this package is unreal! I've found a lot of utility at work and for leisure PWAs. With that being said, something I did notice is that the applications' performance when deployed would tend to be hurt by a few render-blocking resources. I deployed my application to shinyapps.io and tested the performance with lighthouse: https://eval.shinyapps.io/__ye/
image

The results were similar using gtmetrix.com

I noticed in a few of the files the dependencies point to a local file instead of a cdn served asset. Specifically:

Some might not be available on a cdn at the moment, but here are the framework7 and f7icon assets in a cdn. Being able to:

  • reduce these front-loaded scripts
  • changing them to async calls or;
  • serving more assets

could give the servers a bit of relief when generating the front end for users. To give you an example, the estimated gtmetrix runtime in the link shared above is 2.6s and the result estimates load time savings of ~40%.

Thanks again for a great package!

Just in case, here are the dependencies in my environment when I deployed it.


R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                    LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] jsonlite_1.7.2.9000    forcats_0.5.0          stringr_1.4.0          dplyr_1.0.2            purrr_0.3.4            readr_1.3.1           
 [7] tidyr_1.1.2            tibble_3.1.1           ggplot2_3.3.3          tidyverse_1.3.0        shinyWidgets_0.5.4     shinyMobile_1.0.0.9001
[13] rvest_0.3.6            xml2_1.3.2             shiny_1.6.0.9000      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6           lubridate_1.7.9      prettyunits_1.1.1    ps_1.6.0             assertthat_0.2.1     rprojroot_2.0.2      digest_0.6.27       
 [8] packrat_0.5.0        utf8_1.2.1           mime_0.10            cellranger_1.1.0     R6_2.5.0             backports_1.1.10     reprex_0.3.0        
[15] httr_1.4.2           pillar_1.6.0         rlang_0.4.10.9002    readxl_1.3.1         curl_4.3             rstudioapi_0.13      jquerylib_0.1.4     
[22] callr_3.5.1          desc_1.3.0           devtools_2.3.2       selectr_0.4-2        munsell_0.5.0        broom_0.7.5          modelr_0.1.8        
[29] compiler_3.6.3       httpuv_1.6.0         pkgconfig_2.0.3      askpass_1.1          pkgbuild_1.2.0       htmltools_0.5.1.9001 openssl_1.4.3       
[36] tidyselect_1.1.0     fansi_0.4.2          crayon_1.4.1         dbplyr_2.0.0         withr_2.4.2          later_1.2.0          grid_3.6.3          
[43] xtable_1.8-4         gtable_0.3.0         lifecycle_1.0.0      DBI_1.1.0            magrittr_2.0.1       scales_1.1.1         cachem_1.0.4        
[50] cli_2.4.0            stringi_1.5.3        fs_1.5.0             promises_1.2.0.1     remotes_2.2.0        testthat_3.0.1       bslib_0.2.4         
[57] ellipsis_0.3.1       generics_0.1.0       vctrs_0.3.7          tools_3.6.3          glue_1.4.2           hms_0.5.3            rsconnect_0.8.16    
[64] processx_3.5.1       pkgload_1.2.0        fastmap_1.1.0        colorspace_2.0-0     sessioninfo_1.1.1    memoise_1.1.0        haven_2.3.1         
[71] sass_0.3.1           usethis_1.6.3 
@dmenne
Copy link
Contributor

dmenne commented Apr 27, 2021

(I am just a user, not the author):

Using an external CDN should be optional - it might help when you deploy the app on the Internet, but typically we never do this in clinical context, where direct access to Internet resources is blocked by firewalls.

@Esturban
Copy link
Author

@dmenne, I agree. At work we deploy to rstudio connect and would likely have these blocked or alternatively serve them resources to a private CDN. Just something to consider for developing and improving runtime.

@Esturban Esturban changed the title Serve Framework7and shinyMobile assets (CSS and JS) in CDN Serve Framework7 and shinyMobile assets (CSS and JS) in CDN Apr 27, 2021
@DivadNojnarg
Copy link
Member

As mentioned by @dmenne this would be tempting but nobody does this since CDN resources are generally blocked by corporate firewalls and it would not pass on CRAN.

There could be some work to defer scripts but the way htmltools works does not easily allow this: https://unleash-shiny.rinterface.com/web-applications.html#shiny-app-lifecycle. Moreover, some part of the JS cannot be deferred as it is required to initialize the front end layout and the app object.

@DivadNojnarg DivadNojnarg added enhancement New feature or request Framework7 This issue comes from the original template help wanted Extra attention is needed labels May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Framework7 This issue comes from the original template help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants