Why json decode in assets.php

I’m curious why there’s an json decode function in assets.php (gets the assets.json file in the dist folder when you run gulp --production) instead of a simple php file with an array with the same information?

According to my research (link) it’s much slower to decode an json file instead of include a php file with an simple array.

But maybe there’s no difference with such a small .json file?

Because JSON is a data interchange format and PHP isn’t. That file is also from https://github.com/austinpray/asset-builder which can be used outside of PHP.

But like you said, it’s a tiny file and there’s likely zero real-world performance penalty. WordPress loads hundreds (thousands with plugins?) of files on every request.

1 Like