rickparrish / Bootstrap3

Twitter Bootstrap 3.0.0 theme/plugin for GetSimple CMS
4 stars 3 forks source link

Serve Bootstrap sources from CDN #4

Closed PrplHaz4 closed 6 years ago

PrplHaz4 commented 9 years ago

It would be nice to have an option to serve the sources from a CDN. Maybe just a checkbox in the template settings.

Themes could be included as well. http://bootstrapcdn.com/#bootswatch_tab

Implementation-wise, I think this might be a good opportunity to use "stock" filenames with a directory for each theme, which should make updating the library easier....

rickparrish commented 9 years ago

It's easy to use a CDN for the jquery and bootstrap javascript code, and I've been meaning to update that for awhile, so I've just pushed a change that includes this. It'll fallback to a local copy of the .js for the extremely rare cases where the CDN is offline, so I didn't bother adding an option for it on the admin panel.

Using a CDN for CSS with local fallback isn't quite so easy...I'd bet that it's possible, but I can't think of how to do it off the top of my head. Once I find a good example of how to do this, I agree it would be a great idea to use a CDN for that as well.

Any reason why you think subdirectories for each theme would be easier? I find it simplest to load each theme on bootswatch, right-click the .css link, save target as, then select the file to replace. Having a subdirectory would require extra clicks to navigate around before saving.

rickparrish commented 9 years ago

Found a pretty cool snippet at http://stackoverflow.com/a/17232679/342378 that allows for CDN fallback of the bootstrap css.

So now the theme selected by the site admin is loaded via the CDN with local fallback.

If the admin allows users to select their own theme, and a user does select a different theme, then that's still loaded locally...I'm not sure that the CDN can be used for this scenario due to the timing of when the check has to run.

I would guess most people disable the "other themes" menu, so probably not a huge deal anyway.