Performance Optimization
1. HTTP request ... 2. JS loading(React)
Last updated
Was this helpful?
1. HTTP request ... 2. JS loading(React)
Last updated
Was this helpful?
Like third party library, react, google earth.
Async loading
DNS prefetch
Use google WebP, SVG, or jpg/png. Indexed Color. Direct Color. Bitmap
gzip: The gzip format is used in HTTP compression, a technique used to speed up the sending of HTML and other content on the World Wide Web. It is one of the three standard formats for HTTP compression as specified in RFC 2616
Use webpack DllPlugin to split big js file. https://webpack.js.org/plugins/dll-plugin/
Split third party dependencies and your code.
third party library: try to use CDN for not updated code.
Code: split by : first screen / calls times / service and public module
First loading the core page.
<link rel="preload"> https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content
The preload
value of the <link>
element's rel
attribute lets you declare fetch requests in the HTML's <head>
, specifying resources that your page will need very soon, which you want to start loading early in the page lifecycle, before browsers' main rendering machinery kicks in.
link rel="prerender" href="http://example.com"
File is pre render in the backend.
import CSS
Use React.Memo:
export default React.memo((props) => { return ( {props.value} ) });
only {props.item} changes then someProp will recalculate.
function Component(props) { const someProp = useMemo(() => heavyCalculation(props.item), [props.item]); return }
PureComponent implemements shouldComponentUpdate() with a shallow prop and state comparison
const styles = { margin: 0 }; function Component(props) { const aProp = { someProp: 'someValue' } return }
use suspense and lazy
this.functions() = this.functions().bind(this)
Bind the function in the constructor. Not in line binding.
Avoid output data/ setState in render();
import React from 'react';
export class ErrorBoundaries extends React.Component { constructor(props) { super(props); this.state = { hasErrors: false } }
Throttling and debouncing
CSS animation instead of javascript animation
use gzip compress
use web workers