How To Speed Up ACF With Local JSON Guide by Robert Mullineux

How To Speed Up ACF With Local JSON

Mastering ACF Efficiency: Unveiling Local JSON Magic

Facebook
Twitter
Reddit

Advanced Custom Fields (ACF) is an invaluable time-saving asset for numerous WordPress developers. Nevertheless, as datasets grow in size, ACF queries can become time-consuming if not executed efficiently.

However, on large websites with multiple field sets, it can lead to performance degradation. Every time a page loads, the database is queried to retrieve relevant fields and their associated data. This can significantly increase the volume of database queries.

A game-changing solution called Local JSON can drastically alleviate this issue. Local JSON was introduced as a fresh feature in ACF version 5 and is accessible to users of Advanced Custom Fields Pro.

How does ACF integrate with JSON?

Local JSON is an invaluable feature that preserves field groups, post types, taxonomies, and option pages as JSON files within your theme. This concept is akin to caching and delivers a twofold benefit: accelerating ACF and permitting version control over field settings.

The essence of this mechanism lies in ACF storing all field groups as JSON files in the theme folder. Consequently, whenever a page is accessed and fields are loaded, they are retrieved from these files rather than from database queries.

Furthermore, this approach facilitates field management using a Version Control system. This ensures synchronization across local, staging, and production environments.

Setting Up ACF JSON:

To commence utilizing the local JSON feature, establish a fresh folder within your theme and label it as “acf-json.” It is imperative that this folder has write permissions granted to the server (typically, 755 permissions suffice).

After the folder creation and saving of a field group, post type, taxonomy, or options page in the ACF admin, ACF will automatically store that item in a JSON file within the designated folder.

ACF JSON Folder Structure
ACF JSON Folder Structure
ACF JSON Files
ACF JSON Files

Upon the creation of the JSON file, ACF will source the pertinent settings from it. This considerably diminishes the volume of database calls during page loading, thereby enhancing performance.

Additionally, it’s recommended to create an ‘index.php’ file in the ‘acf-json’ folder. This can remain empty, serving to enhance security as the folder remains inaccessible for public browsing:

wp-content/themes/theme_name/acf-json/index.php

Ready to supercharge your WordPress development? Unlock the potential of ACF with Local JSON and witness a remarkable boost in performance and efficiency. Enhance your projects with expert-level optimisations and take your website development to the next level. Get started today and request a free quote online.

Facebook
Twitter
Reddit

Get In Touch