Skip to content

Commit

Permalink
Use base64 data URL for the main PDP image to improve lighthouse perf… (
Browse files Browse the repository at this point in the history
#106)

* Use base64 data URL for the main PDP image to improve lighthouse performance score.

* bump version
  • Loading branch information
markbrocato authored Jun 15, 2020
1 parent 02e4076 commit cec56c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/mock-connector/product.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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),
Expand All @@ -50,5 +49,8 @@ async function getPageData(id) {
],
}

const mainProductImage = result.product.media.full[0]
mainProductImage.src = await getBase64ForImage(mainProductImage.src)

return result
}

0 comments on commit cec56c0

Please sign in to comment.