Skip to main content

Posts

Brought up your Website's Google Page Speed upto 90+

 Hi Guys, If you are running or developing a website you may encounter low Google page speed, So let's dig deeper into the technical guide of Google Page Speed Insights to ensure a good score. Google defines page speed in two ways: How long it takes to display content above the fold. How long it takes a browser to fully render the page. The tool has two main things: Field Data,” or the performance data Second, it measures your page performance via the Lighthouse API. This is called “Lab Data” Field Data  or  Core  Web Vitals : First Contentful Paint (FCP): The time it takes for the first text or image asset to load. Largest Contentful Paint (LCP): The time it takes for the largest text or image asset to load. First Input Delay (FID): The time it takes for the browser to respond to the user’s first interaction. Cumulative Layout Shift (CLS): This measures any movement of the page in the viewport. Lab Data  : Speed Index:  The time it takes for the content to visually appear duri

Error: Ensure text remains visible during webfont load [Resolved]

 Hi Guys, If you are running or developing a website you may encounter this error on Google page speed or GtMetrix, We should consider the following approach to get rid of this error. Suggestion 1: Load the fonts from your server, Even if you are using google fonts you should download and host it on your server.   Suggestion 2:  Use the font-display: swap CSS property while implementing custom fonts, this means the system default fonts will be loaded first and then the custom font is visible, hence text will remain visible.

C++: 9. File Handling

Files are used to store data in a storage device permanently. File handling provides a mechanism to store the output of a program in a file and perform various operations on it. Example of opening/creating a file    #include<iostream> #include<fstream> using namespace std; int main() { fstream new_file; new_file.open("new_file",ios::out); if(!new_file) { cout<<"File creation failed"; } else { cout<<"New file created"; new_file.close(); // Step 4: Closing file } return 0; } Writing to a File #include <iostream> #include <fstream> using namespace std; int main() { fstream new_file; new_file.open("new_file_write.txt",ios::out); if(!new_file) { cout<<"File creation failed"; } else { cout<<"New file created"; new_file<<"Learning File handling"; //Writing to file new_file.close();

C++: 8. Polymorphism

Polymorphism is an important concept of object-oriented programming. It simply means more than one form. That is, the same entity (function or operator) behaves differently in different scenarios. Function Overloading in C++ In C++, two or more functions can have the same name if the number and/or type of parameters are different, this is called function overloading. Example:-  #include <iostream> using namespace std; int add(int a, int b) {     return a+b; } int add(int a, int b, int c) {     return a+b+c; } double add(double a, double b) {     return a+b; } int main() {   int x = 3, y = 7, z = 12;   double n1 = 4.56, n2 = 13.479;   cout<<"x+y = "<<add(x,y)<<endl;   cout<<"x+y+z = "<<add(x,y,z)<<endl;   cout<<"n1+n2 = "<<add(n1,n2);   return 0; } Output:-  x+y = 10 x+y+z = 22 n1+n2 = 18.039 Function Overriding in C++ When a member function of a base class is redefined in its derived class with the same

C++: 7. Inheritance

In C++, inheritance is a process in which one object acquires all the properties and behaviors of its parent object automatically. In such way, you can reuse, extend or modify the attributes and behaviors which are defined in other class. In C++, the class which inherits the members of another class is called derived class and the class whose members are inherited is called base class. The derived class is the specialized class for the base class. Single Level Inheritance When one class inherits another class, it is known as single level inheritance. Example:-  #include <iostream>   using namespace std;    class Account {      public:      float salary = 60000;     };      class Programmer: public Account {      public:      float bonus = 5000;        };        int main(void) {        Programmer p1;        cout<<"Salary: "<<p1.salary<<endl;          cout<<"Bonus: "<<p1.bonus<<endl;         return 0;   }   Output:-  Salary: 6

C++: 6. Constructors

A constructor is a special type of member function that is called automatically when an object is created. In C++, a constructor has the same name as that of the class and it does not have a return type. C++ Default Constructor A constructor which has no argument is known as default constructor. It is invoked at the time of creating object. Example:-  #include <iostream>   using namespace std;   class Employee    {      public:           Employee()             {                 cout<<"Default Constructor Invoked"<<endl;             }     };   int main(void)    {       Employee e1; //creating an object of Employee        Employee e2;        return 0;   }   Output:-  Default Constructor Invoked  Default Constructor Invoked  C++ Parameterized Constructor A constructor which has parameters is called the parameterized constructor. It is used to provide different values to distinct objects. Example:-  #include <iostream> using namespace std; class Employee {

C++: 5. Friend function

If a function is defined as a friend function in C++, then the protected and private data of a class can be accessed using the function. By using the keyword friend compiler knows the given function is a friend function. For accessing the data, the declaration of a friend function should be done inside the body of a class starting with the keyword friend. Syntax:- class class_name     {         friend data_type function_name(argument/s);            // syntax of friend function.   };     Example:-  #include <iostream>     using namespace std;     class Box     {         private:             int length;         public:             Box(): length(0) { }             friend int printLength(Box); //friend function     };     int printLength(Box b)     {        b.length += 10;         return b.length;     }     int main()     {         Box b;         cout<<"Length of box: "<< printLength(b)<<endl;         return 0;     }     Output:-  Length of box: 10   Chara