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
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="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
gzip: The gzip format is used in , a technique used to speed up the sending of and other content on the . It is one of the three standard formats for HTTP compression as specified in
Use webpack DllPlugin to split big js file.
<link rel="preload">
The preload
value of the element's attribute lets you declare fetch requests in the HTML's , 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.