HTML5 Boilerplate: difference between script.js and plugins.js?

I cannot find a definitive answer to the template documentation, but can someone clarify the difference between plugins.js and script.js? I'm new to javascript and I am tempted to just put all my scripts in one file ... is there any good reason not to do this?

+1
source share
3 answers

From the FAQ :

Script.js should contain your main script application. It makes sense to store it in an object literal and execute it based on body classes .

Plugins that I use for jQuery plugins and other third-party scripts. I add jQuery plugins inside closure (function($){ ... })(jQuery); to make sure they are in the protective blanket of the jQuery namespace, especially if they were written by more amateur developers. See Also jQuery Plugin Authoring .

+1
source

in the plugins.js file you get several helpers in the kit, this probably means that you won’t change it at all (or at least not so often), and script.js is the file ready for your ... yes scripts .;)

what you said is true - in production it is usually better to serve the browser with one file instead of many. however, in development it is easier to keep things separate. that the reason the template comes with a script construct that combines all your scripts into one, so you don’t have to worry about that.

0
source

in scripts β†’ your own scripts in the nests β†’ do not touch it!

During the assembly process, both files are combined into one unique and compressed file ...

0
source

Source: https://habr.com/ru/post/955100/


All Articles