Giter VIP home page Giter VIP logo

Comments (2)

Cecilxx avatar Cecilxx commented on July 21, 2024 1

项目中大多使用React + Webpack:

React

  • {...this.props} 不要滥用,请只传递component需要的props
  • props state 尽可能的简单,扁平化,props传的太多或者传得太深,都会加重shouldComponentUpdate里面的数据比较负担
  • 多使用Functional Component (不需要使用组件的生命周期)和 PureComponent (与普通Component的区别在于重写了shouldComponentUpdate方法,会对state和props进行浅比较)
  • 建议引入Immutable.js,可以配合shouldComponentUpdate方法,手动改变返回值
  • ::this.handle 需要绑定this的方法,一律放在construtor里面,放在render里面每次渲染都会绑定一次
  • 合理的组件拆分,避免一个组件过于庞大

Webpack

  • 公共代码提取,webpack <= 3 版本可以使用CommonsChunkPlugin插件
  • 代码分割(异步加载),webpack 2 可以使用require.ensure(),webpack 3可以使用() => import()

from frontend-interview.

evilrescuer avatar evilrescuer commented on July 21, 2024

补充:

webpack性能优化:https://juejin.im/post/5b652b036fb9a04fa01d616b

from frontend-interview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.