Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap-sass Gem v.s. CDN

Various Ruby on Rails tutorials encourage the instillation of the bootstrap-sass gem. Why is this a convention rather than point to a CDN?

I've included in header of my app:

  <!-- BOOTSTRAP CSS 3.3.5 CDN: --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">

And in the footer:

  <!-- BOOTSTRAP JS 3.3.5 CDN --><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" type="text/javascript"></script>

Assuming I am always working from a development box that is connected to the internet: What is the reasoning behind using the bootstrap gem rather than just pointing to a CDN? Isn't it always faster to point to a CDN where a client is likely to have the file already cached?

like image 669
woodenfox Avatar asked Oct 12 '15 04:10

woodenfox


People also ask

Does bootstrap have a CDN?

Bootstrap CDN is a CSS and HTML front-end framework that offers users some basic templates that they can use directly or even modify. It provides tons of examples and dozens of customs bootstrap components, plugins, and elements.

What is bootstrap Sass gem?

bootstrap-sass is a Sass-powered version of Bootstrap 3, ready to drop right into your Sass powered applications.

Is Bootstrap CDN free?

Bootstrap CDN is a free content delivery network that helps us to quickly load Bootstrap CSS, Javascript, and jQuery libraries on our projects to make projects responsive, mobile friendly, and attractive.

Why Bootstrap CDN is used?

It enables users to load CSS, JavaScript and images remotely from its servers. Used by more than 7.9 million websites worldwide (including 30% of the top-10k websites), BootstrapCDN serves more than 70 billion requests a month. In March 2021 the ownership was transferred to the jsDelivr project.


1 Answers

The likely reason that Rails' tutorials suggest the bootstrap-sass gem is just a matter of convenience; as Rails' developers we're used to adding a line to our Gemfile to integrate 3rd party libraries.

There are added benefits to the gem: after you do a bundle install you won't need an internet connection to load your development environment's assets (no need to connect to an external CDN). Also you can use SASS to override Bootstrap mixin variables and customize the framework.

These benefits aside, if you aren't customizing Bootstrap there is no need to use the boostrap-sass gem in production. In fact your argument about clients possibly already having CDN hosted versions of common JS/CSS frameworks is certainly valid.

Short answer: don't think of the boostrap-sass gem as a convention. It's a good starting point for customization but if no customization is needed it is perfectly reasonable to go with a CDN.

like image 176
Sean Huber Avatar answered Oct 09 '22 21:10

Sean Huber