Programmers Blog

Require() vs import

To import JavaScript modules the require() is used, however it is a part of old CommonJS that was initially devised for Node.js (server-side JavaScript). After ES6 (ECMAScript 2015) got released the import keyword became the new standard.

Webpack

Webpack is a Node.js module

In Javascript (on the website frontend) it is not possible to use the require keyword to include other .js files. Webpack solves this by bundling your JavaScript, stylesheets, images, and other resources into a single (or multiple) files.