Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXPERIMENTAL: Atomic styles #21

Open
roman01la opened this issue Sep 19, 2017 · 4 comments
Open

EXPERIMENTAL: Atomic styles #21

roman01la opened this issue Sep 19, 2017 · 4 comments
Labels

Comments

@roman01la
Copy link
Collaborator

Pushed initial implementation into atomic-styles branch 5b2cf7a

The idea is to to have a unique class name per every rule/value pair so style declarations can be reused. In this implementation only static styles are atomized.

It is based on this atomic styles implementation which in turn is inspired by Styletron library

As described in the article linked above this approach has a potential to non-growing stylesheets which reduces output code size. Still this should be measured.

  • No changes to existing Public API
  • Added a new ns cljss.atomic
  • Atomic styles are being aggregated into an atom at compile time, thus it's required to call a macro (cljss.atomic/insert-css!) at the very end of the entry ns (core.cljs) which will generate a sequence of styles insertion calls

Thoughts?

@roman01la roman01la added the idea label Sep 19, 2017
@roman01la
Copy link
Collaborator Author

@brianium Would you mind to test this on your project and report before/after output bundle size?

@brianium
Copy link
Contributor

sure thing - I should be able to check it out tonight or tomorrow.

@brianium
Copy link
Contributor

@roman01la not sure what's going on, but my before and after are the same (both 340K). I also got some warnings when trying out the atomic-styles branch. Here is the output from compiling:

Brians-MacBook-Pro:web brian$ lein cljsbuild once min
Compiling ClojureScript...
Compiling ["resources/public/js/compiled/boojit.js"] from ["src"]...
WARNING: Use of undeclared Var boojit-web.login.views/&:hover at line 64 /Users/brian/projects/boojit/deliveries/web/src/boojit_web/login/views.cljs
WARNING: Use of undeclared Var boojit-web.login.views/&:active at line 62 /Users/brian/projects/boojit/deliveries/web/src/boojit_web/login/views.cljs
WARNING: Use of undeclared Var boojit-web.login.views/&:hover at line 64 /Users/brian/projects/boojit/deliveries/web/src/boojit_web/login/views.cljs
WARNING: Use of undeclared Var boojit-web.login.views/&:active at line 62 /Users/brian/projects/boojit/deliveries/web/src/boojit_web/login/views.cljs
Successfully compiled ["resources/public/js/compiled/boojit.js"] in 9.881 seconds.

Brians-MacBook-Pro:web brian$ du -h resources/public/js/compiled/boojit.js
340K	resources/public/js/compiled/boojit.js

The application still functions for the most part - but pseudo classes don't appear to be functioning - which makes sense given the warnings.

As for file size, it may be that my app is not large enough yet? It is really just login functionality at the moment - but still more components and styles than are in the cljss example.

@roman01la
Copy link
Collaborator Author

@brianium I think I've fixed pseudo-selectors, but anyway, I've also tested this on a somewhat larger amount of styles and surprisingly the output got larger. Let's step aside from this for a while, it's definitely not a priority, at least for now. Maybe I'll get back to this later. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants