Tired of Waiting (Updated)
Written on January 26, 2016
Whenever I run
composer install or
npm install I feel like an old man yelling at young punks to get off my lawn. Especially ever since
npm3. I’ll save you the bitter diatribe and keep this brief.
Creating, distributing, maintaining, and consuming third-party dependencies was supposed to make us more productive and our lives easier. Instead, I feel like I spend more time waiting than coding.
- I have a lot of small projects (e.g. themes and addons) that I want to keep up to date. I package the final outputs, so whenever I can cut a few minutes off a build time, it’s that much easier to fire off updates
- A faster composer install time means a quicker Statamic v2 updater. An update only takes a few seconds if you don’t have any addons with composer dependencies, but once you do it bumps to several minutes. Waiting in a control panel blindly feels like something is broken, so speeding this up drastically is a huge benefit to our users.
So I dug and dug until I found solutions, as one does, and now I’m sharing them with you.
Speeding up Composer
There are two things I’ve found to significantly improve Composer install/update speeds.
1. Disable Xdebug
Stack Overflow to the rescue here. Turn it off and be happy.
2. Use Prestissimo
Prestissimo is a global Composer plugin that installs dependencies in parallel. It is crazy fast. It’s worth noting that Prestissimo requires cURL, which may not work behind certain firewalls or proxies. I haven’t run into any issues at all personally.
I found 4 minute
composer installtimes reduced to under 10 seconds.
Speeding up NPM
Unlike Composer, I’ve found no magic speed boosters for the Node dependency world, but rather two replacements:
ied (soon to be renamed
nom) exists with the goal of covering 80% of the features and commands
npm is used for on a daily basis. It features parallel installs, correct caching, and very nice package directory structure (one folder for each dependency vs hundreds).
I found 6 minute
npm installtimes reduced to 22 seconds.
Because of the (purposely) missing features, you may not be able to use it on every project, but for me and my relatively normal use cases it works just fine.
You may find you need to
npm rebuild node-sass and a few other dependencies once to get them to play nice because of the different directory structure. Keep that in mind, along with the fact that this is also still in alpha.
Loosely based off
ied, pnpm attempts to solve the same problem from a slightly different angle, while aiming to achieve compatibility with npm utilities like
shrinkwrap. Using it will override the features it can improve upon, and pass others through to
I found 6 minute
npm installtimes reduced to 45 seconds.
I’ll add that the visual output is much nicer than both
ied/nom but I’ve seen a few snags with certain components. It’s still alpha. Keep an eye on it.
Happy speed increases!