Bootstrap as a library

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
hatuhay's picture

I always encourage my people to do things the Drupal Way. Even if it is tougher at the beginning, usually pays at the end.

When we started working with Bootstrap we look the "Drupal" way to load the Bootstrap files, what means library style. The surprise was that at the end you need to save the files inside the theme.

A few time later we had the chance to load the files via CDN, but with Bootstrap 3 and the anoying IE8 compatibility we were obligated to install the Bootstap files locally again.

We return to look at libraries compatibility and now found a complex module to do simple things and on version 2.x.x, so we did what we needed to do.

We published a module (https://drupal.org/project/bootstrap_library) that loads via libraries the Bootstrap files installed on /sites/all/libraries/bootstrap, regardless of the theme you are using. It does nothing else.

When using Bootstrap themes it is particulary helpfull to correct Browser Support issues, installing response.js

This module does not depend on a specific version of Bootstrap, it just load the version you install, with the components you install on it, either complete or customize.

Comments

Thanks for the contribution.

pyxio's picture

Thanks for the contribution. I have one question however, can you please explain the advantage of having the bootstrap files in libraries as opposed to being kept in the theme level directory? This has always been a bit confusing to me. Thanks. Cheers Kevin

Why have Bootstrap inside Libraries

sandu.camerzan's picture

Hello, Kevin!

I would say to serve the exact purpose of libraries - share a multitude of resources across site components - jQuery libraries, plugins, frameworks, and I wonder what else.

The real deal is when you have a multitude of components, that try to use the Bootstrap framework. The very basic example you have a site with not one, but a couple of themes, based on Bootstrap. Or you may be developing responsive web application modules, that are intended to be responsive, and you have the markup done, all the Bootstrap classes in place, and you simply want an easy way to test them.

Also, when you build your site around this centralized organized structure, not only will you have less file number and weight, but also you have a easy way to handle it in the future - you always know where it is + it is only ONE single place to download the latest version to.

Sandu Camerzan

Extending previous response...

hatuhay's picture

Using libraries, you have the resource registered in Drupal, so any module can:
- Check if the resource is present.
- Identify version of the files.
- Load it only if needed, instead of loading everywhere.

In the specific case of Bootstrap, today every theme or module writes its own CDN loading code or simply asumes that files were loaded under user's risk.

So using Bootstrap on Drupal is not easy, because what should be simple -loading the files- is not. And what make it worse is that the themes default configuration is not compatible with IE8 and the modules does not provide a solution for people trying to use only the widgets.

Compatible

kemalsunalfilmleri's picture

Does this module suit to the whole versions of Drupal? Thanks for your helpful subject.

Actually Drupal 7. The

hatuhay's picture

Actually Drupal 7.
The development of the Drupal 8 version is in hands of the people of the Bootstrap Theme, they ask me permissions for the repository.
I do not know the status of it.

about compatible

ensklnc's picture

You wrote that "When using Bootstrap themes it is particulary helpfull to correct Browser Support issues, installing response.js" However I could not find response.js in url please help me, thank you :)

şapka promosyon
promosyon şapka

Typo, it is respond.js

hatuhay's picture

Typo, it is respond.js