Answer the question
In order to leave comments, you need to log in
How to build js according to BEM?
I do BEM layout. There are folders with blocks that contain files with JS for these blocks (example-block/example-block.js). Then I glue all the js files into one common one with Galpom.
The crux of the matter: if I use jQuery and the files have $( document ).ready() or $( document ).scroll(), then the resulting file gets a million identical handlers for document. Is this normal and how does it affect performance? Are there any other options for assembling JS, besides stupid gluing?
Answer the question
In order to leave comments, you need to log in
Write in modules, build with Webpack
https://learn.javascript.ru/modules
https://habr.com/post/267639/
https://webpack.js.org/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question