Frontend optimization is a technique of optimizing the delivery of a website from the client side. It involves the fine-tuning of your website to make it more browser-friendly and faster to load. The term “frontend” refers to the interaction between your website and the visitors browser, where your codes are downloaded and displayed.
Overview
Front End Optimization focuses on digging into the code and reducing file sizes or the number of requests needed for a given web page to fully load. Here, several methods are used to streamline the HTML codes and resources to make it easier and faster for the web browser to load pages. As a website becomes larger and continues to use more JavaScript, CSS and Ajax, more …show more content…
The actual page load time is used to benchmark the website 's performance while the theoretical load time is often considered because of its impact on the overall user experience.
Content Delivery Networks (CDNs) are commonly used to streamline majority of the time-critical optimization tasks, which play a very important role in the frontend optimization process. For example, MaxCDN offers performance boosters such as automated compressions, automatic code minification, and pre-pooling connections, which free you from having to manually optimize your web pages.
Front End Optimization Techniques
1. Code Minification
When developing websites, developers tend to make their code more understandable by using comments, descriptive variable names, and whitespaces. Even though it’s a good practice, it increases the amount of data downloaded by the browser. Minification reduces the amount of unnecessary data and bandwidth usage so your visitors download only what they need to display the page.
Example
Before minification
// This script writes “Hello World!” var text = ‘Hello world!’;
function writeText(param) { …show more content…
With compression and streamlining, these files can be reduced to a fraction of their original size to enhance site responsiveness.
Gzip is the most popular file compression utility with the ability to consolidate all code files into a single compressed tarball and decompress them for the entire page to load properly.
Choosing a good image or video format can give you high-quality media in a small package. For images, JPEG is ideal for photos and its size can be greatly reduced by removing fine details. GIF supports animation and PNG supports transparency and also provides high resolutions.
You can use Smush.it or ImageOptim to reduce sizes of your images and also follow the Mightybytes tutorial to optimize videos for the web.
3. Reduce HTTP Requests
When a browser comes across content on a web page, it opens a separate TCP connection for each HTTP request made. Each request makes the page load time longer and can even be limited sometimes to protect the server from being overloaded with a high number of HTTP requests. Reducing the number of requests lets the browser download the webpage faster while reducing your