S
S
sloupone2018-06-12 02:18:43
JavaScript
sloupone, 2018-06-12 02:18:43

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

3 answer(s)
A
Andrey Khokhlov, 2018-06-12
@sloupone

Write in modules, build with Webpack
https://learn.javascript.ru/modules
https://habr.com/post/267639/
https://webpack.js.org/

I
Ivan, 2018-06-12
@Za0r

This tool is great for layout https://parceljs.org

R
Roman Fov, 2018-06-21
@Roman-Fov

There is also ENB for these purposes. And the dock is good on the off site for the assembly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question