Skip to content

Commit cec56c0

Browse files
authored
Use base64 data URL for the main PDP image to improve lighthouse perf… (#106)
* Use base64 data URL for the main PDP image to improve lighthouse performance score. * bump version
1 parent 02e4076 commit cec56c0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-storefront",
3-
"version": "8.10.0",
3+
"version": "8.10.1",
44
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
55
"module": "./index.js",
66
"license": "Apache-2.0",

src/mock-connector/product.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fulfillAPIRequest from '..//props/fulfillAPIRequest'
22
import createProduct from './utils/createProduct'
33
import createAppData from './utils/createAppData'
4+
import getBase64ForImage from 'react-storefront/utils/getBase64ForImage'
45

56
function asciiSum(string = '') {
67
return string.split('').reduce((s, e) => s + e.charCodeAt(), 0)
@@ -32,8 +33,6 @@ export default async function product(params, req, res) {
3233
}
3334

3435
async function getPageData(id) {
35-
console.log('getPageData')
36-
3736
const result = {
3837
title: `Product ${id}`,
3938
product: createProduct(id),
@@ -50,5 +49,8 @@ async function getPageData(id) {
5049
],
5150
}
5251

52+
const mainProductImage = result.product.media.full[0]
53+
mainProductImage.src = await getBase64ForImage(mainProductImage.src)
54+
5355
return result
5456
}

0 commit comments

Comments
 (0)