4

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.
  • looks like just a polyfill to "// Avoid `console` errors in browsers that lack a console." – A. Wolff Sep 28 '13 at 13:07
  • @A.Wolff, ok, and what about the bottom comment: `// Place any jQuery/helper plugins in here.`? Do you know what they mean by that? Should I just load any additional plugins from there? And why? Why not just by putting ` –  Sep 28 '13 at 13:11
  • I don't know bootstrap js. Any link to page where this plugin.js file is used? – A. Wolff Sep 28 '13 at 13:22
  • 1
    @A.Wolff, wait, I found that these are HTML5 boilerplate files. The answer is here: http://stackoverflow.com/questions/4572659/html5-boilerplate-plugins-js. Thanks anyway for your help, appreciate it! –  Sep 28 '13 at 13:32

1 Answers1

1

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.)

Evan Davis
  • 35,493
  • 6
  • 50
  • 57