Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (152).NET Core  (26)Angular  (49)ASP.NET  (48)ASP.NET Core  (64)ASP.NET MVC  (86)Azure  (29)Blazor  (107)DocIO  (20)Essential JS 2  (72)Essential Studio  (164)File Formats  (20)Flutter  (115)JavaScript  (150)Microsoft  (102)PDF  (59)React  (33)Succinctly series  (124)Syncfusion  (490)TypeScript  (30)Uno Platform  (3)UWP  (4)Vue  (26)Webinar  (27)Windows Forms  (55)WinUI  (27)WPF  (123)Xamarin  (132)XlsIO  (24)Other CategoriesBarcode  (4)BI  (29)Bold BI  (4)Build conference  (6)Business intelligence  (53)Button  (4)C#  (108)Chart  (53)Cloud  (10)Company  (445)Dashboard  (6)Data Science  (3)Data Validation  (5)DataGrid  (50)Development  (263)Doc  (7)DockingManager  (1)eBook  (94)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (20)Extensions  (15)File Manager  (4)Gantt  (9)Gauge  (7)Git  (4)Grid  (27)HTML  (9)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (233)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (25)Performance  (7)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (6)Road Map  (9)Scheduler  (29)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (19)Solution Services  (2)Spreadsheet  (10)SQL  (7)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (11)Tips and Tricks  (65)UI  (139)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (1)Visual Studio  (19)Visual Studio Code  (13)Web  (227)What's new  (146)Windows 8  (19)Windows App  (1)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin
8 Simple Checkpoints for a High-Speed Web Page

7 Simple Tips to Speed Up Your Website

These days, people won’t wait long for the content on a website to load. So, it has become mandatory to provide a speedy website that loads in no time. The loading speed will also directly impact your site’s search engine optimization (SEO). In this blog, we will see how to analyze the loading speed of a webpage in a website and improve it.

Contents:

How to analyze the loading speed of a webpage

To analyze the loading speed of a webpage, Google has provided a free tool, PageSpeed Insights. Just enter the page URL and click Analyze. The tool will perform a complete analysis and generate a report. From that report, you can see your website speed and what should be done to improve the webpage’s performance.

Note: Check the speed for both the mobile and desktop devices options with the PageSpeed Insights tool.

Refer to the following screenshot.

PageSpeed Insights tool
PageSpeed Insights tool

Reduce the execution time of JavaScript code

The FID score (first input delay metric) helps us evaluate the JavaScript code execution time and webpage responsiveness. FID is tied to TBT (total blocking time), which is the total amount of time the webpage was blocked. If we reduce the JS execution time, then the browser will quickly compile and execute the JS code. Failing to do so, the browser will delay rendering the JavaScript files.

Google’s Lighthouse is used to improve the quality of your webpages. It evaluates the webpage and measures the page performance, accessibility, best practices, and SEO.

Lighthouse result
Lighthouse result

If the JavaScript execution time is longer than two seconds when loading a page every time, Lighthouse will report an issue.

Reduce the JavaScript execution time

Remove unused code

Usually, an unprocessed JavaScript file will have more lines of unused code. You can identify the unused code using the Google coverage tab developer tool.

Use dead code elimination techniques to optimize the JS code.

Impact of the unused JavaScript in the initial load
Impact of the unused JavaScript in the initial load

Minimize and compress your JS code

You can considerably reduce the JavaScript file size by using minified and compressed versions. There are free online tools available to minimize and compress your JS code. I would recommend using JavaScript Minifier.

Render your scripts from CDN (Amazon S3)

Use a content delivery network (CDN) like CloudFront to load JS code on your webpage. This will quickly load the page and precache the files. CDN files are hosted in different domains and in distributed data centers (DDC) that would be close to the user (who loads your webpage in the browser). Thus, it will quickly download the JS files.

Defer JavaScript loading

By deferring the loading of JavaScript files, you can download only the main content (first contentful paint) of the webpage first.

For more information, refer to Defer JavaScript Loading documentation.

Refer to the following code.

<script type="text/javascript" defer>
/// your JS codes.
</script>

Use compressed images and provide dimensions for images and videos

To enhance the loading speed of your webpage, you should optimize your image to reduce its size and loading time. To do so, provide the image’s width, height, and alt text in the image tag.

Refer to the following code.

<img width="70" height="70" alt="Ease of use" src="https://cdn.syncfusion.com/ease-of-use.svg?v=29062021112846" loading="lazy">

Dialog requesting the user to set the width and height for the image elements

WebP format is standard for images, but it’s not supported in all browsers. For more information, refer to the Image file type and format guide to learn about the supported image formats in web browsers.

You can easily compress an image size and retain good quality using TinyPNG.

If you use any videos (Iframe) on your webpage, then you should set the width and height of the Iframe.

Implement lazy loading

Lazy loading means that only the required data loads initially, and the remaining data loads on demand. Enabling it will help you optimize our webpage and reduce the loading time.

Refer to the following code.

<img width="70" height="70" alt="Ease of use" src="https://cdn.syncfusion.com/ease-of-use.svg?v=29062021112846" loading="lazy">

When using lazy loading, the viewport of the image alone will be loaded. The off-screen images will not load initially. Thus, it enhances your loading speed.

Refer to the following image.
Defer offscreen images

Split your CSS based on device resolution

Say your webpage is responsive and has styles for mobile, tab, desktop, and large desktop form factors. The best approach here is not to use all the responsive CSS code in a single file. Rather, split your CSS based on the device (media query) and use only the required files for that device. This technique will avoid unwanted style rendering on your webpage.

Refer to the following code example.

<link rel="preload" href="/Xamarin-Desktop.min.css" as="style" media="screen and (min-width: 1024px)">

<link rel="stylesheet" href="/Xamarin-Desktop.min.css" type="text/css" media="screen and (min-width: 1024px)">

<link rel="preload" href="/Xamarin-Tab.min.css" as="style" media="(max-width: 1024px) and (min-width: 767px)">

<link rel="stylesheet" href="/Xamarin-Tab.min.css" type="text/css" media="(max-width: 1024px) and (min-width: 767px)">

<link rel="preload" href="/Xamarin-Mobile_v1.min.css" as="style" media="screen and (max-width: 767px)">

<link rel="stylesheet" href="/Xamarin-Mobile_v1.min.css" type="text/css" media="screen and (max-width: 767px)">

By using this technique, you can fix the Eliminate render-blocking resources and Reduce unused CSS issues.

Refer to the following screenshots.

Eliminate render-blocking resources

Reduce unused CSS

Reduce the complexity of the selectors

Avoid the styles (CSS) using traverse selectors, as it takes additional time to find the inner DOM elements of the style when the page loads.

.box:nth-last-child(-n+1) .title {
    /* styles */
}

Remove unused styles

Remove unused CSS styles and the same sort of styling applied to multiple elements with different class names. You should also optimize the structure of applying CSS using a traverse selector. In the following code example, two different variables are defined for the same style, which should be avoided.

.hide {
    display: none;
}

.hidden {
    display: none;
}

Serve static assets with an efficient cache policy

Apply a cache-control header for all the resources loaded. The maximum age set for a resource is a year. This cache policy issue is commonly reported for third-party resources and images used on the page.

For example, in AWS, for a file, add the metadata type System Defined, the key cache-control, and the value max-age=31536000. Here, 31,536,000 corresponds to the total number of seconds in a year.

Conclusion

Thanks for reading! In this blog post, we have discussed the simple steps to improve your webpage speed. These methods will help you reduce the loading time. Follow these awesome tips and build high-performance and responsive webpages!

Syncfusion provides 70+ ASP.NET Core UI controls for application development. We encourage you to take a moment to learn about our products and browse our interactive demos.

If you have any queries, please let us know in the comments section of this blog post. You can also contact us through our support forumfeedback portal, or Direct-Trac. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Share on twitter
Share on facebook
Share on linkedin
Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top