Skip to content

cmonacaps/import_styles_comparison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

import_styles_comparison

two apps:

  • generated using npx create-react-app
  • having equivalent behavior
  • having the same code, except for the imports from ramda

Screen Shot 2020-08-11 at 1 11 21 PM

cra_import_star

This is the idiomatic way to import from ramda.

import * as R from 'ramda';

cra_import_used_by_name

This is a local recommendation.

import { add, apply, chain, compose, curryN, flatten, flip, groupBy, head,
  juxt, lensIndex, lensProp, map, mergeLeft, multiply, objOf, omit, over,
  prop, repeat, set, times, transpose, values, view } from 'ramda';

const R = { add, apply, chain, compose, curryN, flatten, flip, groupBy, head,
  juxt, lensIndex, lensProp, map, mergeLeft, multiply, objOf, omit, over,
  prop, repeat, set, times, transpose, values, view }

impact to production build

file import * import { named } difference
logo512.png 9664 9664 0
logo192.png 5347 5347 0
favicon.ico 3150 3150 0
index.html 2217 2217 0
service-worker.js 1181 1181 0
asset-manifest.json 1035 1035 0
precache-manifest.HASH.js 657 657 0
manifest.json 492 492 0
robots.txt 67 67 0
static/js/2.HASH.chunk.js.map 409641 409640 -1
static/js/2.HASH.chunk.js 146460 146460 0
static/js/main.HASH.chunk.js.map 9250 10367 1117
static/js/runtime-main.HASH.js.map 8276 8276 0
static/js/main.HASH.chunk.js 1855 2320 465
static/js/runtime-main.HASH.js 1557 1557 0
static/js/2.HASH.chunk.js.LICENSE.txt 790 790 0
sum 601639 603220 1581

I.e. in this test the import * as R style saves less than 1% of the build size; they are on par.

Size of app sent to the browser appears similar as might be expected:

import * as

import_star

import { named }

import_named

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published