Performance improvements
-
The ocean_get_google_font_css function within /includes/compatibility/ocean.php isn’t set up to cache the Google fonts URL which is resulting in the URL being requested on every page view. This adds to the backend time by at least .25s. It looks like this function is used to download the font locally which can help with performance, but the local font file is only requested after the look up request.
Is it possible to implement a transient cache something like:
function ocean_get_google_font_css( $url ) { if ( strpos( $url, 'https:' ) === false && strpos( $url, 'http:' ) === false ) { $url = 'https:' . $url; } $transient_name = 'font_request_'.md5( $url ); if ( false === ( $result = get_transient( $transient_name ) ) ) { $request = wp_safe_remote_get( $url, array( 'sslverify' => false, ) ); if ( is_wp_error( $request ) ) { return ''; } else { $result = wp_remote_retrieve_body( $request ); set_transient( $transient_name, $result , 604800 ); } } return $result; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Performance improvements’ is closed to new replies.