S
S
Shaidulint2016-08-07 16:10:19
JavaScript
Shaidulint, 2016-08-07 16:10:19

How to organize Javascript plugin code in multiple files?

Hello, for the first time I am writing a full-fledged js-component for displaying data in the form of a table and a chart. The code is divided into several files:

  • Classes for working with SVG
  • Class for drawing a chart
  • The class of the table itself

With the help of gulp I concatenate these three files into one.
At the moment, all classes are declared in the global window in order to have access from other files.
Can you please tell me a design pattern that would correctly organize the code so that all classes can be accessed from other files and not litter in the global object?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2016-08-07
@SPAHI4

there are loaders for this, I advise Webpack

X
xmoonlight, 2016-08-07
@xmoonlight

Create a prototype that will be the main class of the library, and include everything you need to work in it.
https://learn.javascript.ru/prototype

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question