
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
cjs-vs-amd-benchmark
Advanced tools
It's basic benchmark that compares speed of both systems when used in development mode.
Main point is to show that server-side generation of a bundle on request is not necessarily slower than loading modules asynchronously from the browser. It's actually opposite and difference can be significant. See the results section for numbers.
AMD modules are loaded with RequireJS and CommonJS modules are bundled on request with Webmake.
There's no prebuild step, in both cases modules are loaded/bundled on request. In case of AMD, they're loaded asynchronously in a browser. In case of CJS when request occurs they're read from filesystem, bundled and served in one file.
To see fair results (adequate to your development environment) benchmark needs to be installed and launched locally.
You can also check it working at medyk.org:3700, but mind it's backed with basic Node.js server setup (not very efficient for AMD), and due to extra latency, results will be worse than when running same on your localhost.
Install package:
$ npm install cjs-vs-amd-benchmark
Generate dummy modules (by default it resembles 400 modules tree from existing real world project)
$ npm run setup
You can generate custom number of out of provided modules map:
See bin/default-deps-map.json on how it should be constructed.
$ bin/generate --mapPath=path/to/custom/map
Start server (defaults to port 3000)
$ npm start
If you prefer other port, do:
$ bin/start --port=8080
Load the benchmark on corresponding port, e.g. localhost:3000
Following load times were measured on 2008 MBP with local setups of Node.js and Nginx server, each number is average of 5 runs.
Node.js server setup was very basic, no clusters involved, so concurrency was limited (hence not great results for AMD).
Nginx was configured with Cache-Control: no-cache header, so browser always checks with the server whether new version of module is available.
| Node.js v0.10.13 Google Chrome | Node.js v0.10.13 Firefox | Nginx v1.0.10 Google Chrome | Nginx v1.0.10 Firefox | |
|---|---|---|---|---|
| CommonJS (via Webmake) | 299ms | 273ms | N/A | N/A |
| AMD (via RequireJS) | 896ms | 548ms | 367ms | 569ms |
FAQs
Compare load times of CJS and AMD module systems
The npm package cjs-vs-amd-benchmark receives a total of 3 weekly downloads. As such, cjs-vs-amd-benchmark popularity was classified as not popular.
We found that cjs-vs-amd-benchmark demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.