Skip to content

Commit a320132

Browse files
committed
perf(image): reduce svgo precision for tracedSVGs
1 parent cc7ca32 commit a320132

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

examples/gatsbygram/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "Kyle Mathews <[email protected]>",
77
"dependencies": {
88
"gatsby": "^1.9.52",
9-
"gatsby-image": "^1.0.5",
9+
"gatsby-image": "^1.0.39",
1010
"gatsby-link": "^1.6.20",
1111
"gatsby-plugin-glamor": "^1.6.8",
1212
"gatsby-plugin-google-analytics": "^1.0.8",

examples/gatsbygram/src/components/post.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as PropTypes from "prop-types"
22
import React from "react"
33
import HeartIcon from "react-icons/lib/fa/heart"
44
import Link from "gatsby-link"
5+
import Img from "gatsby-image"
56

67
import { rhythm, scale } from "../utils/typography"
78
import presets from "../utils/presets"
@@ -42,7 +43,6 @@ class Post extends React.Component {
4243
}}
4344
css={{
4445
display: `block`,
45-
backgroundColor: `lightgray`,
4646
flex: `1 0 0%`,
4747
marginRight: rhythm(1 / 8),
4848
width: `100%`,
@@ -61,14 +61,11 @@ class Post extends React.Component {
6161
flexDirection: `column`,
6262
flexShrink: 0,
6363
position: `relative`,
64-
paddingBottom: `100%`,
6564
overflow: `hidden`,
6665
}}
6766
>
68-
<img
69-
src={small.src}
70-
srcSet={small.srcSet}
71-
sizes="(min-width: 960px) 292px, 33vw"
67+
<Img
68+
sizes={{ ...small }}
7269
css={{
7370
margin: 0,
7471
height: `100%`,
@@ -133,9 +130,12 @@ export const postFragment = graphql`
133130
likes
134131
smallImage: image {
135132
childImageSharp {
136-
small: responsiveSizes(maxWidth: 292, maxHeight: 292) {
133+
small: sizes(maxWidth: 292, maxHeight: 292) {
137134
src
138135
srcSet
136+
aspectRatio
137+
sizes
138+
tracedSVG
139139
}
140140
}
141141
}

packages/gatsby-plugin-sharp/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ function encodeOptimizedSVGDataUri(svgString) {
757757

758758
const optimize = svg => {
759759
const SVGO = require(`svgo`)
760-
const svgo = new SVGO({ multipass: true, floatPrecision: 1 })
760+
const svgo = new SVGO({ multipass: true, floatPrecision: 0 })
761761
return new Promise((resolve, reject) => {
762762
svgo.optimize(svg, ({ data }) => resolve(data))
763763
})

0 commit comments

Comments
 (0)