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

Do not use a CDN to get bootstrap, jquery and popper #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LudovicRousseau
Copy link

This patch is NOT complete. A better approach would be to add a --no-cdn command line (or something like that). But I do not know Ruby so I am not able to program that myself.

If the assets are downloaded from a CDN then the loading fails with a Content-Security-Policy error in my case.

Content-Security-Policy : Les paramètres de la page ont empêché le chargement d’une ressource à https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css (« style-src »).

I know I could change the server configuration but it is simpler for me to distribute the files myself from the server.
And this is better for my user privacy.

@mishina2228
Copy link
Owner

Thanks for your PR!

To explain the context, CDN has been used since v2.3.0.
Prior to that, assets bundled with the gem were used.

The reasons for the change to use CDN are as follows:

  • To reduce the size of the gem.
  • Not want to replace assets every time the JS libraries are updated.

I prefer not to bundle assets with the gem, so I would like to take other approaches.
For example, I came up with the idea that if --no-cdn is added to the command line, assets will be downloaded locally from the internet and the view will use them.

What do you think?

@LudovicRousseau
Copy link
Author

Downloading the assets at build time if --no-cdn is used is a very good idea.

I propose to use a cache and download bootstrap & jquery only if not already present (and with the correct hash).

My patch was just a quick hack for my own use.

@mishina2228
Copy link
Owner

I propose to use a cache and download bootstrap & jquery only if not already present (and with the correct hash).

Great idea!
I'm a little busy right now, but would like to tackle this when I have time.

@LudovicRousseau
Copy link
Author

I propose to always download the assets from the CDN (or somewhere else) at run time (and use the cache mechanism). So no need to add a --no-cdn option.

  • the gem will still have a small size
  • it will work for everybody

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants