Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
Should I use 'import and export' for a simple project?

I think I have some misunderstanding of 'import and export'.

There are many modules, eg: React, react-router-dom, etc...

However, I'd like to talk about the simple project, only html, css and Javascript, without nodeJs/ React.

If I spilt my js file in 5 parts...

Method 1: link js directly

<script src="javascript1.js"></script>
<script src="javascript2.js"></script>
<script src="javascript3.js"></script>
<script src="javascript4.js"></script>
<script src="javascript5.js"></script>

Method 2: Import function from js 2,3,4,5

<script type="module" src="Main.js"></script>
<script src="javascript2.js"></script>
<script src="javascript3.js"></script>
<script src="javascript4.js"></script>
<script src="javascript5.js"></script>

I tried the method 2 and I found it's break.

As there are many global variables in my project...

Finally, it shows error / some variable not found during import the function from other js.

Is there any pros of using 'import and export' for a simple project?

or

just use method 1, link the js file directly.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda