daattali / shinycssloaders

⌛ Add loading animations to a Shiny output while it's recalculating
https://daattali.com/shiny/shinycssloaders-demo/
Other
399 stars 45 forks source link

Suggestion: consolidate all CSS files into one file #37

Closed daattali closed 4 years ago

daattali commented 4 years ago

Right now there's one css file per spinner type, plus a fallback css. There's no technical reason that they can't all be included in one file, and then the browser would be able to cache this one. The downside is that the file will be larger, but it's still tiny and negligible.

andrewsali commented 4 years ago

What's the advantage compared to caching the individual css files?

daattali commented 4 years ago

For a browser, loading one file of size X is much more efficient than loading two files of size X/2. If you have two different loader types on one page, instead of loading two files you'll only load one. And if I have one app that uses loader type 1, and later I go to a different app that uses loader type 2, the browser would already have the file cached if they're in the same file. Reducing the number of file requests is a very common technique in web development to make loading time much more efficient, even if the single file is larger. Shiny itself also uses a similar technique, for example in the source code there are individual JS files for each input type, but they all get concatenated together into one file when used in shiny apps. It's also similar to the concept of CSS sprite maps.

andrewsali commented 4 years ago

I was working under the assumption that most people use 1 (at most 2) different spinner styles in any given project, in which case the separate files are probably more efficient ;)

But I don't want to nitpick, I am also perfectly fine with a single file, it's tiny amount of code anyways.

daattali commented 4 years ago

Oh I absolutely agree that 90+% of uses are with the default type! This would just simplify the code and if there were 100 types then there'f be a difference in downloading the file, but currently the file would be so small that it wouldn't take any longer to download.

I was going to say the same thing as your last sentence :) I'll leave this open for now until I resolve the CRAN issues and return from vacation, you as the original author shall have the last word.

On Wed., Jan. 15, 2020, 00:31 andrewsali, notifications@github.com wrote:

I was working under the assumption that most people use 1 (at most 2) different spinner styles in any given project, in which case the separate files are probably more efficient ;)

But I don't want to nitpick, I am also perfectly fine with a single file, it's tiny amount of code anyways.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/andrewsali/shinycssloaders/issues/37?email_source=notifications&email_token=AAHIQFCWVY3OBXMY6MQCJULQ52NRJA5CNFSM4KF3UQGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI7DRXQ#issuecomment-574503134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHIQFH4SGRX56PVEZ7HJETQ52NRJANCNFSM4KF3UQGA .