Slow Checkout loading
-
I’m not sure when this started being an issue, but the checkout page will load very slowly when using Microsoft Edge with this plugin active. It seems to be working fine on Google Chrome.
The issue is caused by the huge amount of cities being added to the City Select element in the billing/shipping forms. For Romania, that is about 13000 cities, and it halts the page loading for about 1 minute while it’s creating and adding all those options.
This only happens when there isn’t a county/state already selected. If there is a county/state selected, the City Select element will only contain the cities from the selected county/state, which is fine.
I don’t understand why all the cities need to be added to the Select before the page is even rendered, since the City Select will be disabled until a county/state is selected, at which point the City Select element will be populated with the cities from thewc_city_select_params
javascript object. So we never need all the cities to be present in the select.
My quick fix was to comment the line 147 from wc-city-select.php, which says this:array_walk_recursive( $cities, array( $this, 'add_to_dropdown' ) );
If no city is added to the$this->dropdown_cities
property, no option element has to be created. I’m sure there is a more elegant solution, but I needed something that works, and this works, without breaking the existing functionality.
- The topic ‘Slow Checkout loading’ is closed to new replies.