WordPress Page Speed Optimization Website(90+ GTMetrix)

WordPress PageSpeed Optimization

Hey bloggers, are you worried about speed of your WordPress website or blog and wants to boost page speed of your wordpress website. Then you’re at a right place, because In this article, I’m going to share with you some best tips and tricks. These tips and tricks will help you to enhance page speed of you WordPress blog.

Whatever tips and tricks I’m going to share with you are personally applied on my own blog. After the implementing all these given suggestion, your page speed score will be more than 90+ on GtMetrix. So, If you want to enhance load time of your WordPress blog then please stick with the article till the end.

Why Good Page Speed in WordPress Matter?

There are some advantages of having fast loading website:

  • SEO(Ranking): Due to huge competition, Google always try push those blog, which has good page speed and load fast.
  • Lower Bounce Rate: When you website loads fast then bounce rate automatically reduces. It leaves good impression towards google ranking.

There are a lot of different aspects where having good page speed will be beneficial for you.

GUIDE To Boost Page Speed Of WordPress Blog:

There are some plugins and tips that I’m going to share with you. So, If you want to boost pagespeed of your blog then read this article till the.

First, let’s start with the Top WordPress plugin which will help you to boost the page speed of your website.

WordPress Plugin To Optimize WordPress Speed

There are various plugins available for WordPress that will help you to optimize the performance of your website. But I’m going to share top 3 WordPress plugins that I personally use to optimize the speed of my WordPress blog.

1. a3 Lazy Load:

It’s one of the best plugins that I’ve ever seen. Because It will help and improve your page speed with lazy loading technique. whenever a user will be visits your website, then a3 lazy load plugin stops all images from being load. It only loads relevant and currently viewable images of your website. Instead of loading all the images of your WordPress blog at one time, It will load images only then when users will scroll it down.

Click Here(Download)

2. WP Fastest Cache:

Another main reason behind the slow page speed of your blog is their JS and CSS files. Because, by default, these files are not compressed and minified. Here, WP Fastest cache will help you to minify and compress your HTML, CSS, and JS files.

You can also enable browser caching option of this plugin, which will reduce page load time for repeated visitors by using the caching method.

In this given image, I’ve shown what settings I made in it:

WordPress Seo: Page Speed Optimization

Click Here(Download)

3. Page Speed Ninja:

It’s almost similar to WP Fastest cache except It has one important additional feature called leverage browser caching option. But I’ll recommend you not to use it If you’re not getting any warning related to this leverage browser caching in your GTMetrix report.

Important: Minify JS might break some exteranl JS Scripts features, If you're already using... Once you've applied minify JS option, then please check functionality of your website.

According to me, these 3 basic plugins would be enough for your WordPress website. Because I’ve been using these plugins for the last 6 months and It works fine for me.

Click Here(Download)

But there is also a plugin called Assets CleanUp, which is used to remove those plugins, which has not any use in homepages while someones visit your website.

WordPress Themes To Optimize Page Speed

let’s move to another main factor, which is themes. Because when you’re using optimized and fast themes then you don’t need to focus too much on optimization side.

There are two best themes that I would like to recommend to you:

1. ASTRA WP – WordPress theme

At the time of writing this post, I’m using this ASTRA WP theme. It’s a well-optimized and fast loading theme and there are also different types of customization options to enhance UI.

Click Here(Download)

2. GeneratePress – WordPress theme

It’s one of the best lightweight and fast loading themes. It’s one of those themes, which totally focused on their speed optimization. It has currently more than 300K+ active installations with more than 4.7 Ratings. You can also adopt this theme.

Click Here(Download)

WordPress IMAGE Optimization Techniques:

Now, Let’s talk about Image Optimization techniques. Because I think this one of the important factors that directly affect the page speed of your WordPress website. I’ve seen lot of peoples are using more than 200kb+ size logo images. Which is not necessary at all, I think so.

Even though newbie bloggers are just downloaded the stock photos from stock websites like pixels, etc. Then they directly upload them on their website. we know that the size of stock photos is almost about 500Kb+ because of their larger pixels. We don’t need that much larger size of images to display on our blog. That’s why we will compress our images and will reduce its size by 50-80%.

Let me tell you one thing that there is an also inbuilt function inside the WordPress website that we can use to resize it. But I’ve been using separate software for all image optimization. because In the software, I’ve lots of different options that efficiently optimize my images as per my need.

I’ve Image Optimization application for both the platforms Windows and Android.

Mass Image Compressor(For Windows)

It’s the image compressor software for windows that I’ve been using for months. In this software, You need to select the folder, where you’ve stored your all images that you want to compress. After then, just customize the setting according to your need and then click on the compress all button. It will compress all the images within that folder.

Click Here(Download)

Here is a screenshot of the software, When I was compressing my images.

WordPress Seo: Image Compressing 90+ GTMetrix Speed

Read Also: How To Add Email Subscription To WordPress Blog

Image Compressor(For Android)

It’s the lightweight and perfect application that you can use to compress your images directly through your android smartphones. You just need to select the images that you want to compress and then select the size and format of your images. you can also change the extension(format) of your images with this application.

Click Here(Download)

Compress Images With Android Smpartphones: WordPress page speed optimize

Now go and analyze again your website in GTMetrix. Now you will see your page speed score would be at least 80+. So, I hope you all will like this article related to WordPress Seo.

Thank’s To Read…

You may also like

Django Rest Framework – Create REST API, Serializers, CRUD

Django Rest Api, Serializers

Hey Coders, If you’re here then definitely you have a good know about Django framework and How it works. In this article, I’m going to explain your Django Rest Framework. Basically, we’ll discuss what is Django Rest Framework and how you can create a Rest API with this Rest Framework.

What is Django Rest Framework?

Django rest framework is a toolkit or package that allow you to create restful Web API with an ease. It’s easy to use if you’ve knowledge Django framework. Because we all know that API is an interface that help us to to interact with other software’s in the market. So, having a knowledge of API will be good for you as a developer.

Creating Simple Django Project:

Project Overview* – First let’s create a simple Django app, which basically shows us List of movies, and later on we will create our rest api with Django Rest Framework. In this Django App, we will have different type of model fields e.g title, category, date_released and price. Which we will fetch under the table element inside the main template.

To start a new project in a Django, simply type a following command under the terminal. Let’s create a project called “movie_api

django-admin startproject movie_api

And then it will create a folder called movie_api, which contains your project. Here, I’m using PyCarm IDE because It’s basically designed for Python related task. Now get inside your “movie_api” folder by using “cd movie_api” command in terminal. Rrun the following code to check whether you project working properly or not.

python manage.py runserver

Go to the browser and enter http://127.0.0.1:8000/ url in address bar. If you will see something like below then congrats, you’ve successfully created your project.

Django Homepage

Creating an App:

Now, Let’s create an app, where we will configure our files like models.py, views.py, etc. Let’s create your app by using following command:

python manage.py startapp movie

Remember one thing, Our main project folder name is “movie_api” and the app we just created is called “movie“. Now, once you’ve created your app then you have to this list this app under movie_api/settings.py. Here, under the array INSTALLED_APPS, you need to add your newly created app.

movie_api/settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'movie',  # Newly Created app
]

Now let’s create our model field that we needed for our movie list.

movie/models.py

from django.db import models

class Movie(models.Model):
    title = models.CharField(max_length=100)
    category = models.CharField(max_length=100, blank=True)
    date_released = models.DateField() 
    price = models.IntegerField()

    def __str__(self):
        return self.title

Now run the migration and migrate by using following command in the shell.

python manage.py makemigrations

and then

python manage.py migrate

Now, To display your database under you django administration, you have to configure your movie/admin.py file.

movie/admin.py

from django.contrib import admin
from .models import *

admin.site.register(Movie)

Now, Let’s configure our django administration… To access your Django admin panel, you need to create a superuser account. To create a superuser to access django admin panel, type following command in the shell or terminal.

python manage.py createsuperuser

Now, you type the above command then it will ask you to enter username, email and passwords. Just follow the instruction and create your account. Once you’ve created your superuser then you can access django admin panel.

To access django admin panel, Go to the address 127.0.0.1:8000/admin.

Now login with your username and password and then it will redirect you to the dashboard look like this:

Django Administration

Now Let’s create some objects through admin panel. Later on, we will create our REST API of these data by using Django Rest Framework.

Django Model Objects - Django Rest Framework

In the above image, you can see that I just created 5 Movie object, and now we will display it on our homepage. After then we will create an API of these data. But before that let’s configure our urls.py and templates file

Now create a urls.py file under movie app and link this urls.py with movie_api/urls.py

movie_api/urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('movie.urls')),
]

And now let’s configure our main app urls.py file.

movie/urls.py

from django.urls import path
from movie import views

urlpatterns = [
    path(' ', views.home, name="home"),
]

Now Let’s create our home function under the movie/views.py. Where we will call our home.html template that we will create after configuring views.py file.

movie/views.py

from django.shortcuts import render
from .models import *

def home(request):
    movies = Movie.objects.all()
    context = {
        'movies': movies
    }
    return render(request, 'movie/home.html', context)

Now let’s create a folders called templates/movie/ inside your movie app folder. And then create a file called home.html. Because here our main is about creating REST API, therefore I will not waste too much time too design this home template. In this home.html, we will have simple table with bootstrap look. where we will fetch our Movie objects.

movie/templates/movie/home.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Movie REST</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
</head>
<body>

<!--Navbar-->

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
  <a class="navbar-brand" href="#">Movie API</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item active">
        <a class="nav-link" href="#">API</a>
      </li>
    </ul>
  </div>
        </div>
</nav>


<div class="container">
    <div>
    <h1>Movies Table</h1>
        <table class="table table-striped table-dark">
      <thead>
        <tr>
          <th scope="col">Name</th>
          <th scope="col">Category</th>
          <th scope="col">Release Date</th>
          <th scope="col">Price(INR)</th>
        </tr>
      </thead>
      <tbody>
      {% for movie in movies %}
        <tr>
          <th scope="row">{{movie.title}}</th>
          <td>{{movie.category}}</td>
          <td>{{movie.date_released}}</td>
          <td>{{movie.price}}</td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
    </div>
</div>

</body>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
</html>

Now run your server again and you will see something like this.

Movie List Website- Django Rest Framework

In the above, you can see that our table fetched all the data from our model objects. Now we’re going to build main section our blog. Now, we can create our REST API by using Django Rest Framework.

REST API(Creat,Read Update, Delete) – Django Rest Framework:

Now, we will create our REST API and our url will be:

  • View API: “/api”
  • Create API: “/api/create”
  • Update API: “/api/update/id”
  • Delete API: “/api/delete/id”

Now let’s begin our REST API tutorial with installing and setup out Django Rest Framework.

Installing And Setup Django Rest Framework:

install django rest framework package by using following command-

pip install djangorestframework

Now add ‘rest_framework’, inside your INSTALLED_APPS under the settings.py file.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'movie',
    'rest_framework',
]

In Django Rest Framework, we’re using basically 4 types of requests i.e. GET, POST, PUT And DELETE. Now first, we’re going to create our view api that will show our all movie in structured format.

Under the movie/views.py, you need to import some module and classes.

from rest_framework.decorators import api_view  
from rest_framework.response import Response

In above, you can see that we imported api_view, where we will define that what requests we will be use in view functions. And then in we imported Response, which will allow us to access the interface of Django rest framework.

Now, you need to create “serializers.py” file inside your movie folder. In serializers.py, we will define that which model we want to serialize.

movie/serializers.py

from rest_framework import serializers
from .models import Movie

class MovieSerializers(serializers.ModelSerializer):
    class Meta:
        model = Movie
        fields = '__all__'

In the above code, you can see that our code is much similar like model form. Where we have serialized all fields of our Movie model. Now import this file into your movie/views.py.

from .serializers import MovieSerializers

Now, we’re ready to define our function and url to create REST API.

Creating API( READ):

Now, let’s create our Api, that will show list of our all movie in structured format. To create api, first we need to define a function under the views.py. First, Let me show you the function that I’ve defined to create api.

movie/views.py

@api_view(['GET'])
def MovieList(request):
    movies = Movie.objects.all()
    serializer = MovieSerializers(movies, many=True)
    return Response(serializer.data)

In the above MovieList function, we have use ‘GET’ request that will show you list, which is only readable. Under this, we called all the object that we want to define in our api. Then we used MovieSerializersn function, where we have defined movies variable. In this movies, we stored our all objects data, and then many=”true”, which means field that we want to display in our api list.

In the last, we simply returned a Response function that will use serializer variable to display this under Django Rest Framework. Now, we need to setup our url path, where we will define our path of this api. Add following path under urls.py file

movie/urls.py

path('api/', views.MovieList, name='api'),

Now go to the respective url: https://127.0.0.1:8000/api and you will see your API of Movie list is created successfully like this:

Rest Api with Django rest framework

API – Adding Object(CREATE)

To adding data through an API, we have to use POST response. Let me show you my code first then I’ll explain you.

movie/views.py

@api_view(['POST'])
def MovieCreate(request):
    serializer = MovieSerializers(data=request.data)

    if serializer.is_valid():
        serializer.save()
    return Response(serializer.data)   

In the above code, we have used POST request and then we store requested data into serialized. And then later, if the form is valid then we will save it into our database. In the last, we returned Response objet as same as previous one.

Now add following url path into your movie/urls.py file

path('api/create/', views.MovieCreate, name="api_create"),

Now Go to the url: https://127.0.0.1:8000/api/create, and then you will be see form like this:

Creating API in Rest Framework

And then click on the post… It will add the data into database and display it into your api list like this:

Adding object with Django rest framework

API – Updating Object(UPDATE)

Now, Let’s update our data through REST Framework. First, let me show you my code and then I will explain you.

movies/views.py

@api_view(['POST'])
def MovieUpdate(request, pk):
    movie = Movie.objects.get(id=pk)
    serializer = MovieSerializers(instance=movie, data=request.data)

    if serializer.is_valid():
        serializer.save()
    return Response(serializer.data)

Here, we’re also using POST request, because we need to send data in order to update our data. It has same code structure like Creating, but here we need to open specific object using their “id”. Then we will enter our updated data and click on the post.

Now add following path to into your urls.py to access this function.

movie/urls.py

path('api/update/<str:pk>/', views.MovieUpdate, name="api_update"),

In the above url path, you need to insert id of respective post in address bar, which data you want to update.

Updating Data with Django rest framework

You can see in the above image that we’re updating our movie object with ‘id’=1. edit the data that you want to update and your data will be successfully updated.

Data updated in Rest Api, Crud

API – Deleting Object(DELETE)

Now, we’re going to delete data through Django Rest Framework. But first let me show you my code.

movie/views.py

@api_view(['DELETE'])
def MovieDelete(request, pk):
    movie = Movie.objects.get(id=pk)
    movie.delete()
    return redirect('api')

In the above code, we have called ‘DELETE‘ request. Here, we don’t need to serialize our data. we just called an object through their id and stored it into movie variable. Now you need to call delete() function to delete your called object.

Now you need to add following url path to access delete function:

 path('api/delete/<str:pk>/', views.MovieDelete, name="api_delete"),

In place of <str:pk>, insert id no. of the object that you want to delete. Now go to the above url path and you will see page like this.

Deleting object with Django Rest Framework

Your object is successfully deleted out of your database and Api list.

Deleted Data from Rest API - Django CRUD

That’s it for today. If you want to learn more advance topic then you can follow Django REST Documentation: Click Here(To Read)

Read Also: Django authentication – Sign Up, Sign in And Log out(Read Here)

I’ve explained all the basic things and term that you need to understand in Django rest framework. Now you can learn more advance things in Django rest framework by using your curiosity.

If you liked this this article then please don’t forget to share this article with your friends and social media groups.

Thank’s To Read…

You may also like

Automation With Python Selenium (Browser Automation)

Automation With Python Selenium (GUIDE):

Hey Learners, Today we’re back with interesting topic of Python Programming. In the real world, there are lots of repetitive nature of task that we’re doing again and again in same pattern. In the Python, We have a package called Selenium, Which helps us to automate some tasks that are repetitive in nature. Python Selenium specially allow us to automate browser related tasks that we’re going to learn today.

What is Browser Automation?

Browser automation is process where our bots operates our browsers as per our given instruction. We all know that Python is also popularly known for their automation task. With Python selenium, you can automate your browser for tasks like Filing Html Forms, Repetitive works and testing element, etc.

Learning Python Selenium package is whole different scenario that would take hours of time. So, here I will only give you the basic guide about specific task called Browser automation with Selenium. If you’re curious about learning this selenium then read the blog up to the end.

Prerequisite:

  • Python(installed)
  • Selenium Package(Installed) – pip install selenium

Now let’s begin our basic guide about Python Automation with selenium.

First, We need to download compatible Web-Driver of respective browser in order to automate our browser. Below, you can have download web-driver of your respective browsers.

Chromehttps://sites.google.com/a/chromium.org/chromedriver/downloads
FireFoxhttps://github.com/mozilla/geckodriver/releases
Edgehttps://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Safarihttps://webkit.org/blog/6900/webdriver-support-in-safari-10/
Browser Web Drivers

Because I have chrome browser therefore I will download Web Driver of chrome browser. Please confirm the version of your browser that you’re using before downloading their driver.

Once you will have downloaded Web Driver of your respective browser then just you have to put it on the right place. In Windows, You need to extract your chromedriver.exe inside the C:/ Drive. But If you have a mac then copy it into “cp chromedriver / usr/local/bin/” directory.

Browser Automation Coding:

Now our coding part will start. Let me tell you that what we’re going to automate today with Python Selenium.

In this automation, our code will open the GitHub website and then It will click on the login button. After then it will find username and password box and fill-up the credentials that we defined in our code. In the last, it will submit and logged into that users account.

First Let me show you my code that I’ve written to automate above task, after then I’ll break and explain each and every line of code.

Browser Automation(Python Code):

from selenium import webdriver

PATH = "C:\chromedriver.exe"
browser = webdriver.Chrome(PATH)
browser.get('https://github.com')

sign_in = browser.find_element_by_link_text('Sign in')
sign_in.click() 

username_box = browser.find_element_by_id('login_field') 
username_box.send_keys('your username')

password_box = browser.find_element_by_id('password')
password_box.send_keys('Your Password')
password_box.submit()

Let’s Define each line of code one by one.

In Line 1, First We have to import webdriver class from selenium module. Then we to store our path location of web driver into variable(PATH). So that we can use this path later on in this code.

In Line 4, Here enter your Path parameter into Chrome(PATH) method of webdriver class. Then stored it into variable called browser. So, that we’re able to access our webdriver.

In Line 5, You need to use get(url) method to open your url into your web-driver that we have stored in our browser variable. Which means browser.get(‘https://github.com/’) will open this website into our automated chrome browser.

In Line 7, We have used find_element_by_link_text(‘Sign in’) to find Sign in text that contains link on our homepage. Because In homepage of github, we have only one ‘Sign In’ text that contains link.

Python Automation

In Python we can have access element by various methods e.g link text, class, id, tag name, xpath, css selector etc.

In Line 8, we will perform click action on the sign_in variable by using click() method. Because In sign_in variable, we have stored our Sign in link text.

Login Automation(GitHub):

In login Page of GitHub, Now you need to inspect element to find class or id of username or password input box. In chrome browser, right click and then click on inspect button. Here you can find that what input box contains what class or id.

Selenium Automation Basic Guide.

Now we will find ‘id’ attributes of both username and password input box. So that we can find element in our code by using that particular id.

Accessing Element in Python Selenium

Now, we have both ‘id‘ attributes for both input field like username and password. For Username (id = ‘login_field’) and password(id = ‘password’). Now let’s continue our code.

In Line 10, We will find username field by using find_element_by_id(‘login_field’) and stored this element into variable called username_box.

In Line 11, Now we need to send text or string to that username field. Here we have send_keys() method to send our username to username_box. you need to define your username of github inside your send_keys(‘username‘).

In Line 13,14 , We will apply same trick as Line 10,11 to find password field and sending our password.

In Line 15, You just need to call submit() method on our passoword_box to submit this form.

That’s it. Now run your code and you will see our code will automatically open the browser, click on the link and fill up the details as per given instruction in our code.

You May Also Like: Web Scrapping Basic Guide With Python Language(Read)

So, I hope You got something useful and interesting from here. if you want to learn programming, frameworks and new technologies then please don’t forget to subscribe this blog.

We’re uploading such kind of programming related contents on daily basis. Don’t forget to recommend this blog to your friends too.

Thank’s To Read…

You may also like