user1694077
user1694077

Reputation:

What are the bootstrap main.js and plugins.js scripts for?

Plugins.js and main.js are included with initializrs version of twitter bootstrap 3 (maybe also in the vanilla bootstrap 3, I haven't checked). I don't know what they're there for, couldn't find any explanation on getbootstrap.com and the files themselves don't contain a lot of explanatory comments.

Can anyone explain what they're there for, what they're supposed to do? To me, it looks like plugins.js is meant to load any additional javascript you want to include. Is that right? And why would you do it like that?


These are the contents of plugins.js (main.js is empty):

// Avoid `console` errors in browsers that lack a console.
(function() {
    var method;
    var noop = function () {};
    var methods = [
        'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
        'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
        'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
        'timeStamp', 'trace', 'warn'
    ];
    var length = methods.length;
    var console = (window.console = window.console || {});

    while (length--) {
        method = methods[length];

        // Only stub undefined methods.
        if (!console[method]) {
            console[method] = noop;
        }
    }
}());

// Place any jQuery/helper plugins in here.

Upvotes: 4

Views: 9509

Answers (1)

Evan Davis
Evan Davis

Reputation: 36592

As you discovered, these are part of HTML5 Boilerplate, not Bootstrap.

The plugins.js file is where you could include all of your jQuery or other helper plugins.

The main.js file is for your main application scripts, the code that would instantiate and use the plugins.

These files are minified and cache-busted by the H5BP build script. (You'll notice the scripts section of the main HTML template is fairly strict about how you reference the scripts so that it can be updated during the static build.)

Upvotes: 1

Related Questions