Blog Single

25 Jul

Web site Page speed depend on

Page speed depend on

  • Quality of your host.
  • Physical size of the site, generally due to images.
  • Number and quality of the plugins used.
  • Number of external scripts running on the site and to implement those.

We can do:

1. Reduce Render render-blocking

If we want to reduce render-blocking we can follow this tutorial

// add async and defer to javascripts
function nsbd_defer_javascripts ( $url ) {
if ( FALSE === strpos( $url, ‘.js’ ) ) return $url;
if ( strpos( $url, ‘jquery.js’ ) ) return $url;
return “$url’ async=’async”;
}
add_filter( ‘clean_url’, ‘nsbd_defer_javascripts’, 11, 1 );

 

The piece of code below in your theme’s functions.php file will remove query strings from static resources. This ensures that they are cached like other elements.

function nsbd_remove_script_version( $src ){
return remove_query_arg( ‘ver’, $src );
}
add_filter( ‘script_loader_src’, ‘nsbd_remove_script_version’, 15, 1 );
add_filter( ‘style_loader_src’, ‘nsbd_remove_script_version’, 15, 1 );

2.  Keep Leverage browser caching for page loading

If we want browser caching we can do this with htaccess file

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType text/html “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType text/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 1 month”
</IfModule>
## EXPIRES CACHING ##

 

3. Optimized Images and set actual size of images

For this when we make images then need to optimized and set actual size and css sprite

4. Minify JavaScript and Css

For this need make manually

5. Delete unnecessary Plugins
6. Also we can use CDN and Cache

7. PageSpeed: Enable gzip compression

In htaccess file need to add

For Apache

You will need to add the following lines to your .htaccess file:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

.

Related Posts