Image

Steps to implement lazy loading for javaScript

1. Combine all the JS files

The first to do is, we have to combine all the third party and the custom javascripts into a single file.

2. Minify the JS

Now, minify the javascript file using the minification tools available.

3. Giving the set out time

The "src" which is highlighted in the below screenshot is the path of the minified JS file. We have give setout time so that scripts load only after the given time. In this way, other Web Core Vitals doesn't effect.

4. Defining the function

Apply the below mentioned function in order to lazy load the javascript.

5. Lazy loading the pixels

Apply the below mentioned function and set out time in order to lazy load the pixels.

5. Lazy loading the intercom chat

Apply the below mentioned function and set out time in order to lazy load the intercom chat.

Conclusion

We at NectarSpot, follow all the above mentioned steps to improve the Web Core Vitals.

Read Next: Improve Web Core Vitals Score by reducing Server Response Time ➞

Receive latest marketing insights, data and inspiration

View Blogs ➞ Subscribe ➞

Start your Project Today

Get Started