S
S
smuz2018-07-24 17:16:41
css
smuz, 2018-07-24 17:16:41

How is the component approach implemented in the web in practice?

Recently I went through a test task and received feedback that the task was not solved in a component way: it is impossible to add such js and css to the site, otherwise it will break everything else. Before that, I have not come across collaborative development, so I am interested in how the css and js isolation is implemented in practice, how the integration and code maintenance is convenient. Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Victor P., 2018-07-25
@Jeer

It depends on what you are working with, if es2015, then modularity mechanisms are built in through export / import, if something earlier, then you can do it through require. When using frameworks, the schemes may differ slightly, but everything is based on dependency injection (for example, Angular 1 and Angular 2+). If you're using jQuery, you can wrap your code in jQuery modules, which isn't difficult either.
There are also many practices and methodologies with css, for example, in angular it comes out of the box, but assemblers, for example, webpack, are used for correct work. In general, you should never override global element styles, you can wrap your page in a div with a unique complex id, and any styles you add should come with that id first. But, as I said, there are many methodologies, google, study.

P
Pavel Novikov, 2018-07-24
@paulfcdd

Through webpack, for example

A
Andrey Titov, 2019-01-21
@titov_andrei

Web components: a look into the future
Implementing a component approach on the web: an overview of web...
Web components: an overview and use in production

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question