All Projects → theKashey → jsx-compress-loader

theKashey / jsx-compress-loader

Licence: other
⚛️JSX optimisation loader to reduce size of React application

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to jsx-compress-loader

sizeof-loader
Webpack loader that works like url-loader (or file-loader) but with extracted information such as image dimensions and file-size.
Stars: ✭ 20 (-50%)
Mutual labels:  loader, webpack-loader
Thread Loader
Runs the following loaders in a worker pool
Stars: ✭ 945 (+2262.5%)
Mutual labels:  loader, webpack-loader
Inject Loader
💉📦 A Webpack loader for injecting code into modules via their dependencies.
Stars: ✭ 474 (+1085%)
Mutual labels:  loader, webpack-loader
Markdown Loader
markdown loader for webpack
Stars: ✭ 335 (+737.5%)
Mutual labels:  loader, webpack-loader
Style Loader
Style Loader
Stars: ✭ 1,572 (+3830%)
Mutual labels:  loader, webpack-loader
Sass Loader
Compiles Sass to CSS
Stars: ✭ 3,718 (+9195%)
Mutual labels:  loader, webpack-loader
Stylefmt Loader
Webpack-loader. Fixes stylelint issues automatically while bundling with Webpack.
Stars: ✭ 24 (-40%)
Mutual labels:  loader, webpack-loader
markup-inline-loader
a webpack loader to embed svg/MathML to html
Stars: ✭ 24 (-40%)
Mutual labels:  loader, webpack-loader
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (+180%)
Mutual labels:  loader, webpack-loader
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (+162.5%)
Mutual labels:  loader, webpack-loader
typed-css-modules-loader
💠 Webpack loader for typed-css-modules auto-creation
Stars: ✭ 62 (+55%)
Mutual labels:  loader, webpack-loader
Rust Native Wasm Loader
Stars: ✭ 156 (+290%)
Mutual labels:  loader, webpack-loader
nunjucks-loader
Webpack loader for Nunjucks templates
Stars: ✭ 20 (-50%)
Mutual labels:  loader, webpack-loader
Css Loader
CSS Loader
Stars: ✭ 4,067 (+10067.5%)
Mutual labels:  loader, webpack-loader
webpack-modernizr-loader
Get your modernizr build bundled with webpack, use modernizr with webpack easily
Stars: ✭ 35 (-12.5%)
Mutual labels:  loader, webpack-loader
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (+1410%)
Mutual labels:  loader, webpack-loader
image-minimizer-webpack-plugin
Webpack loader and plugin to compress images using imagemin
Stars: ✭ 180 (+350%)
Mutual labels:  loader, webpack-loader
angular-translate-loader
"angular-translate" loader for webpack
Stars: ✭ 15 (-62.5%)
Mutual labels:  loader, webpack-loader
Svgr
Transform SVGs into React components 🦁
Stars: ✭ 8,263 (+20557.5%)
Mutual labels:  loader, webpack-loader
Vue Pretty Logger
The console is more cool to use, easier to debug, and more fun log output. Enjoy the vue-pretty-logger in the vue project.
Stars: ✭ 150 (+275%)
Mutual labels:  loader, webpack-loader

jsx-compress-loader


JSX optimization webpack loader

What it does

Replaces React.createElement by a local variable, thus reduce "number of characters" per React Element from 17 to 1, as long local variable would be uglified.

  • "a.b.createElement".length === 17,
  • "React.default.createElement".length === 27.
  • usually - about 23 after all optimizations and transplications.
  • this solution - 1

That is not a problem for Preact or Inferno, only to "default" React, as long only React has got "long element creation". See this tweet from Dan Abramov, to find more about it.

This technique also is almost NOT affecting gzipped size, only the real amount of js code, browser has to parse.

Bonus

This also removes object property access (ie React.createElement), thus:

  • speeding up Chrome by 5%
  • speeding up Safari 11 by 15%
  • speeding up Safari 12 by 35%
  • not speeding up Mobile Safari 12(iPhone XS)
  • here is the test

Would it help?

Just open your bundle, and count createElement inside. Or open any page, and count closing tags </. Next multiply by 22. Result is - amount of bytes you would remove from your bundle. For free.

Usage

Just add this webpack loader AFTER all other.

  • after ts
  • after js
  • after svg -> react -> babel -> js
  • and dont forget to apply it to node_modules as well.

in terms of webpack configuration - "after" goes "before", ie top-most loader is the "last" one.

Only for ESM modules!

babel "modules" should be "false" - you already should have it, for proper tree-shaking, and this is what this library is counting on.

As separate loader

rules: [
  {
    test: /\.js$/, // for any js file in your project
    use: 'jsx-compress-loader',
  },
  {
    test: /\.js$/,
    exclude: /node_modules/,
    use: 'babel-loader',    
  },
];

As chained loader

rules: [
  {
    test: /\.js$/, // paired with babel loader
    exclude: /node_modules/,
    use: [    
      'jsx-compress-loader'
      'babel-loader',
    ],
  },
];

Other ways

Licence

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].