Description
What version of Tailwind CSS are you using?
v3.4.10
What build tool (or framework if it abstracts the build tool) are you using?
postcss 8.4.41
What version of Node.js are you using?
v22.6.0 (also Deno 1.46.0-rc.3+dd8a9c5)
What browser are you using?
- N/A
What operating system are you using?
macOS
Reproduction URL
https://github.com/marvinhagemeister/tw-config-hash-repro
Steps to reproduce:
- Clone https://github.com/marvinhagemeister/tw-config-hash-repro
- Run
npm i
- Run
node foo.mjs
-> observe time printed to console - Edit
node_modules/tailwindcss/lib/util/hashConfig.js
and replace the contents of the hashing function withJSON.stringify(config)
function hashConfig(config) { - return (0, _objecthash.default)(config, { - ignoreUnknown: true - }); + return JSON.stringify(config); }
- Run
node foo.mjs
again -> observe much faster time
Describe your issue
I noticed that hashing the tailwind configuration takes up roughly a third of the time in my project. That seemed a bit much. It looks like the object-hash
package isn't the fastest.
tailwindcss/src/util/hashConfig.js
Lines 3 to 5 in f07dbff
Given that the config is mostly json, switching to JSON.stringify
would be much faster. If we do want to treat some values in a special way when the config isn't pure json, we could pass a custom replacer function to JSON.stringify
for those.
Here is a quick diff:
function hashConfig(config) {
- return hash(config, { ignoreUnknown: true });
+ return JSON.stringify(config);
}
Before 84ms:

After 6.33ms:

Whilst this is just a synthetic example repository, I can reproduce the same results in real world projects of mine.
Project | Before | After |
---|---|---|
Reproduction repo | 84ms | 6.33ms |
Project A | 207ms | 19ms |
Project B | 301ms | 24ms |
It might not seem like much in the grander scheme of thing, but in my projects where I do tailwind processing during development this makes HMR updates feel a tiny bit snappier. There the time hashing the configuration easily takes up 30-35% of the total tailwind processing time. Would be nice if that could be reduced.