问题
i can't find any definitive answer on the boilerplate docs, but can someone clarify the difference between plugins.js, and script.js? i'm a javascript newbie, and am tempted to just put all my scripts in one file... is there a good reason not to do this?
回答1:
From the FAQ:
Script.js should hold your primary application script. It might make sense to store it in an object literal and execute it based on body classes.
Plugins I use for jQuery plugins and other 3rd party scripts myself. I put the jQuery plugins inside of the
(function($){ ... })(jQuery);
closure to make sure they're in the jQuery namespace safety blanket, especially if they were written by more amateur developers. See also jQuery Plugin Authoring.
回答2:
in plugins.js
file you get few helpers bundled, it's probably meant to include stuff you won't modify at all (or at least not so often), while script.js
is a file ready for your... yes, scripts. ;)
what you said is true - in production, it's usually better to serve the browser one file instead of many. however in development it's easier to keep things separated. that's the reason why boilerplate comes with a build script, which combines all your scripts into one so you don't have to worry about this.
回答3:
in scripts -> your custom scripts in plugings -> don't touch it!
In build process both files unite into one unique and compressed file...
来源:https://stackoverflow.com/questions/5520565/html5-boilerplate-difference-between-script-js-and-plugins-js