Load Google fonts faster
particle// Load Google fonts add_action( ‘wp_head’, ’themeprefix_load_fonts’ ); function themeprefix_load_fonts() { ?>
// Load Google fonts add_action( ‘wp_head’, ’themeprefix_load_fonts’ ); function themeprefix_load_fonts() { ?>
// Make pagespeed happy //——————— function remove_style_id($link){ return preg_replace(“/ id=’.*-css’/”, “”, $link); } add_filter(‘style_loader_tag’, ‘remove_style_id’);
function load_style(){ if ( WP_LOCAL_SERVER || WP_STAGING_SERVER ) { wp_register_style( ‘client-stylesheet’, WP_CONTENT_URL .’/build/css/style.css’, array(), substr(chunk_split((substr(filemtime(get_stylesheet_directory() . ‘/../../build/css/style.css’), -3)), 1, ‘.’), 0, -1), ‘all’ ); } else { wp_register_style( ‘client-stylesheet’, WP_CONTENT_URL .’/build/css/style.min.css’, array(), substr(chunk_split((substr(filemtime(get_stylesheet_directory() . ‘/../../build/css/style.min.css’), -3)), 1, ‘.’), 0, -1), ‘all’ ); } wp_enqueue_style( ‘client-stylesheet’ ); } add_action( ‘wp_enqueue_scripts’, ‘load_style’ );
/** * Disables WordPress Rest API for external requests * Change whitelist plugins when plugins need to use the REST API */ function restrict_rest_api_to_localhost() { $whitelist = array(‘127.0.0.1’, “::1”); $whitelistplugins = array(‘contact-form-7’, ‘redirection’); $request = $_SERVER[‘REQUEST_URI’]; $die = true; if ($request) { foreach ($whitelistplugins as $plugin) { if (!empty(strpos($request, $plugin))) { $die = false; } […]
# BEGIN GZIP COMPRESSION mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* # END GZIP COMPRESSION
ini_set(‘display_errors’,’Off’); ini_set(‘error_reporting’, E_ALL );
// Defer Javascript loading function js_async_attr($tag){ # Do not add defer or async attribute to these scripts // $scripts_to_exclude = array(‘script1.js’, ‘script2.js’, ‘script3.js’); // foreach($scripts_to_exclude as $exclude_script){ // if(true == strpos($tag, $exclude_script ) ) // return $tag; // } # Defer or async all remaining scripts not excluded above return str_replace( ‘ src’, ‘ defer=”defer” […]
ul li::before {content: “•”; color: @yellow;}