Search code examples
pagespeedgoogle-pagespeedlighthouse

How to get a screenshot and show it to the user after the audit page speed?


I recently working with API page speed google, Now I want to show thumbnail screenshot after the audit. But I don't know how to get a screenshot from the user's site?


Solution

  • When API returns JSON has the lighthouseResult object that includes audits object, you can find thumbnails array in the screenshot-thumbnails.

    In this case, I've used:

    lighthouseResult.audits['screenshot-thumbnails'].details.items[9].data; 
    
    

    Also, you can get final-screenshot :

    lighthouseResult.audits['final-screenshot'].details.data;
    

    Notice: data is base64.