Wordpress - Speed of reading a json file vs having it hardcoded in the same file?
I need to run the following
acf_add_local_field_group($array)
about 15 times, with the total amount of lines in the array passed in, from all calls, adding up to about 7500 lines. I am wondering what the difference in speed would be between the two following scenarios:
- The arrays are hardcoded in the same file
-
Every top level array is put into a json file in a directory called
acf-json.
The second method is preferable to me, but I am worried about the performance cost of having to read the contents of 15 different files that total 7500 lines. This will run every time for wordpress (it is called in functions.php), so I don't want to incur a performance hit.
I could cache the files, but the cache would need to be flushed any time new code is pushed from github, so I'm not sure how that could be done, especially since we can't use any 3rd party caching plugins
Solutions
Why you don't use PHP arrays instead of Json files?, in that way you don't have to open the file but require it and do what ever you want.