Need advice about which tool to choose?Ask the StackShare community!

RequireJS

8.8K
3.2K
+ 1
307
Webpack

40.1K
27.1K
+ 1
752
Add tool

RequireJS vs Webpack: What are the differences?

Key Differences between RequireJS and Webpack

  1. 1. Module Loading Approach: RequireJS uses an asynchronous module loading approach where modules are loaded on-demand as the dependencies are resolved. On the other hand, Webpack uses a bundling approach where all the modules and their dependencies are bundled into a single file, resulting in a static dependency graph.

  2. 2. Configuration: RequireJS requires a separate configuration file (require.config) where you specify the module paths and dependencies. In contrast, Webpack uses a single configuration file (webpack.config) that provides a more centralized and flexible way to manage the entire build process.

  3. 3. Code Splitting: RequireJS does not have built-in support for code splitting, which makes it harder to split application code into smaller bundles and load them asynchronously. In contrast, Webpack has built-in support for code splitting, allowing developers to easily split their code into separate chunks and load them on-demand, resulting in faster initial page loads.

  4. 4. Loaders: RequireJS does not support loaders by default, making it harder to preprocess files or perform transformations on the imported modules. On the other hand, Webpack has a powerful concept of loaders, which allows developers to preprocess and transform different types of files, such as CSS, JSON, and images, using loaders.

  5. 5. Hot Module Replacement: RequireJS does not have built-in support for hot module replacement, which means that developers need to manually refresh the page when making changes to the code. In contrast, Webpack has built-in support for hot module replacement, enabling developers to see the changes instantly without a page refresh, making the development process more efficient.

  6. 6. Community and Ecosystem: RequireJS has been around for a longer time and has a mature ecosystem with a wide range of plugins and extensions available. However, Webpack has gained popularity in recent years and has a large and active community, offering extensive documentation, tutorials, and a wide range of plugins to enhance the development experience.

In summary, RequireJS and Webpack differ in their module loading approach, configuration, code splitting, support for loaders, hot module replacement, and community ecosystem. Webpack provides a more modern and flexible way of managing JavaScript modules and has several advantages over RequireJS, such as built-in code splitting and hot module replacement support.

Decisions about RequireJS and Webpack
Aleksandr Filatov
Contract Software Engineer - Microsoft · | 4 upvotes · 282.9K views
Why migrated?

I could define the next points why we have to migrate:

  • Decrease build time of our application. (It was the main cause).
  • Also jspm install takes much more time than npm install.
  • Many config files for SystemJS and JSPM. For Webpack you can use just one main config file, and you can use some separate config files for specific builds using inheritance and merge them.
See more

We mostly use rollup to publish package onto NPM. For most all other use cases, we use the Meteor build tool (probably 99% of the time) for publishing packages. If you're using Node on FHIR you probably won't need to know rollup, unless you are somehow working on helping us publish front end user interface components using FHIR. That being said, we have been migrating away from Atmosphere package manager towards NPM. As we continue to migrate away, we may publish other NPM packages using rollup.

See more
Get Advice from developers at your company using StackShare Enterprise. Sign up for StackShare Enterprise.
Learn More
Pros of RequireJS
Pros of Webpack
  • 79
    Open source
  • 69
    Modular script loader
  • 66
    Asynchronous
  • 49
    Great for AMD
  • 30
    Fast
  • 14
    Free
  • 309
    Most powerful bundler
  • 182
    Built-in dev server with livereload
  • 142
    Can handle all types of assets
  • 87
    Easy configuration
  • 22
    Laravel-mix
  • 4
    Overengineered, Underdeveloped
  • 2
    Makes it easy to bundle static assets
  • 2
    Webpack-Encore
  • 1
    Redundant
  • 1
    Better support in Browser Dev-Tools

Sign up to add or upvote prosMake informed product decisions

Cons of RequireJS
Cons of Webpack
    Be the first to leave a con
    • 15
      Hard to configure
    • 5
      No clear direction
    • 2
      Spaghetti-Code out of the box
    • 2
      SystemJS integration is quite lackluster
    • 2
      Loader architecture is quite a mess (unreliable/buggy)
    • 2
      Fire and Forget mentality of Core-Developers

    Sign up to add or upvote consMake informed product decisions

    - No public GitHub repository available -

    What is RequireJS?

    RequireJS loads plain JavaScript files as well as more defined modules. It is optimized for in-browser use, including in a Web Worker, but it can be used in other JavaScript environments, like Rhino and Node. It implements the Asynchronous Module API. Using a modular script loader like RequireJS will improve the speed and quality of your code.

    What is Webpack?

    A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows to load parts for the application on demand. Through "loaders" modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.

    Need advice about which tool to choose?Ask the StackShare community!

    Jobs that mention RequireJS and Webpack as a desired skillset
    What companies use RequireJS?
    What companies use Webpack?
    See which teams inside your own company are using RequireJS or Webpack.
    Sign up for StackShare EnterpriseLearn More

    Sign up to get full access to all the companiesMake informed product decisions

    What tools integrate with RequireJS?
    What tools integrate with Webpack?

    Sign up to get full access to all the tool integrationsMake informed product decisions

    What are some alternatives to RequireJS and Webpack?
    Browserify
    Browserify lets you require('modules') in the browser by bundling up all of your dependencies.
    JavaScript
    JavaScript is most known as the scripting language for Web pages, but used in many non-browser environments as well such as node.js or Apache CouchDB. It is a prototype-based, multi-paradigm scripting language that is dynamic,and supports object-oriented, imperative, and functional programming styles.
    Git
    Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
    GitHub
    GitHub is the best place to share code with friends, co-workers, classmates, and complete strangers. Over three million people use GitHub to build amazing things together.
    Python
    Python is a general purpose programming language created by Guido Van Rossum. Python is most praised for its elegant syntax and readable code, if you are just beginning your programming career python suits you best.
    See all alternatives