Support

Account

Home Forums Feature Requests Anyway to store the JSON from PHP Reply To: Anyway to store the JSON from PHP

  • Thanks Elliot,
    Well after a bunch of testing I finally found the main culprit.

    First off, it seems that JSON does not have a speed advantage over PHP.
    Not in my tests anyway. Which for me is good as I want stick with PHP.

    However, I did test upgrading to ACF5 and that increased the Speed drastically.
    Page load went from 15sec to 2sec.

    So I started looking as to why.
    it seems it mainly had to do with the “page-link” field.
    In ACF4 this field prints out the Select field and all the options. This is normal, but because the client has a few hundred posts, few hundred pages, products, casestudies, etc. The Select dropdowns were outputing about 1,000 option fields. On Top of that we are using Flexible Content and therefore there can be quite a few “page-links” on the page. This was causing the post.php file to be 4.4mb. This was making the page load extremely slow. In ACF5 you have switched this out for an Ajax Dropdown. So no more thousands of options in select fields. This took the page size down to 974kb.

    Even though this helped a lot I would suggest looking into ways to reduce the amount of markup. It seems something that my team can do is reduce the size of the key fields, but I would ask that you look into reducing the markup.

    This seems quite long for an id:
    id=”acf-field_52eda830feeb1-acfcloneindex-field_row_boxes_52f2da031b44e-acfcloneindex-field_row_boxes_10001″
    I know it needs to be unique, but maybe you can hash it or something to reduce the size as this is also used in the “for” attribute. Maybe also look into reducing the amount of tags, white-space, etc.

    To get around this issue in ACF4 you would need to change your “page-links” to “text” fields and have the client input the URL or have them input the Post ID. This is not ideal, but it would decrease the load on the page.

    Because of this our team will look at incorporating ACF5 much sooner.

    There are some minor issues with it like the new Dropdowns show the entire post title. My clients use really long titles. This makes the admin all wonky as items don’t line up. I am sure I can work around this with a CSS fix, but I will post this in another Thread.

    Thanks

    Also if anyone needs this info here is how I found converting PHP into JSON:

    
    foreach (acf_get_local_field_groups() as $group)
    {
    	$group['fields'] = acf_get_local_fields($group['key']);
    	echo json_encode($group, JSON_PRETTY_PRINT);
    }