From cec56c0932c600e23e519bbe3f53e4c2b3a27190 Mon Sep 17 00:00:00 2001 From: Mark Brocato Date: Mon, 15 Jun 2020 13:47:33 +0300 Subject: [PATCH] =?UTF-8?q?Use=20base64=20data=20URL=20for=20the=20main=20?= =?UTF-8?q?PDP=20image=20to=20improve=20lighthouse=20perf=E2=80=A6=20(#106?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use base64 data URL for the main PDP image to improve lighthouse performance score. * bump version --- package.json | 2 +- src/mock-connector/product.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index dfca55ce..8227f140 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-storefront", - "version": "8.10.0", + "version": "8.10.1", "description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.", "module": "./index.js", "license": "Apache-2.0", diff --git a/src/mock-connector/product.js b/src/mock-connector/product.js index baf103a6..575770a9 100644 --- a/src/mock-connector/product.js +++ b/src/mock-connector/product.js @@ -1,6 +1,7 @@ import fulfillAPIRequest from '..//props/fulfillAPIRequest' import createProduct from './utils/createProduct' import createAppData from './utils/createAppData' +import getBase64ForImage from 'react-storefront/utils/getBase64ForImage' function asciiSum(string = '') { return string.split('').reduce((s, e) => s + e.charCodeAt(), 0) @@ -32,8 +33,6 @@ export default async function product(params, req, res) { } async function getPageData(id) { - console.log('getPageData') - const result = { title: `Product ${id}`, product: createProduct(id), @@ -50,5 +49,8 @@ async function getPageData(id) { ], } + const mainProductImage = result.product.media.full[0] + mainProductImage.src = await getBase64ForImage(mainProductImage.src) + return result }