Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!