Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

334
Visualizações
What is the difference between a js file and a js module?

I tried to search, but cannot find precise / concise answer to this question. It appears to be used loosely and interchangeably, IMO. Anyone can teach me?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Good question!

Background: JavaScript files used to be very small but as the JavaScript language has become more popular, the JavaScript files have become so large that "modules" were introduced to to help break up the JavaScript code into smaller, more manageable pieces.

So what does this mean?

Simply put, a module is a javascript file that has been structured into a smaller, more manageable file size.

Here is a article on MDN Web Docs that goes into greater detail:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

In the example below main.js is a javascript file that is not a module, but both canvas.js and square.js are javascript modules. All 3 are javascript files but canvas and square are broken out into their own files to be more manageable.

Example:
index.html
main.js
modules/
canvas.js
square.js

Image of above example

Here is a link to the code on Github for the example above: https://github.com/mdn/js-examples/tree/master/modules/basic-modules

about 4 years ago · Juan Pablo Isaza Relatório

0

Well we can get really technical here.

A file is anything on an OS that can handle IO information storage, of which there are various types i.e. text files and directories. A directory is a specific type of file that allows other files to be stored within.

When you speak about a "js file" it's sort of slang for "a text file that has a .js extension and javascript within".

In modern javascript modules are used to create more cleanly separated and reusable modular pieces of code, which can be exported and imported into other modules (technically files). They're sort of like namespaces in other languages (not really but sort of) but each file can only have a single namespace (module).

You can also have js files that are not modules, all modules are files but not all files are modules.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda