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

Runtime code (smaller and quicker) for production #398

Closed
rxaviers opened this issue Feb 17, 2015 · 12 comments
Closed

Runtime code (smaller and quicker) for production #398

rxaviers opened this issue Feb 17, 2015 · 12 comments

Comments

@rxaviers
Copy link
Member

PR #436

Goal

On client side, performance is also about how fast our page loads. So, size matters. How to get the smallest/leanest bundle for production?

Suppose we need a plural function for English. That is what we need: a function that given a number, outputs the plural form. But, in order to get that, we need the English plural rules (from CLDR) and the library code to parse that rules in order to generate this simple function function( count ) { return count == 1 ? "one" : "other"; }. In the end, this tiny thing is what matters. What if we could precompile that at build time and deploy only this tiny function.

Our goal is to allow our formatters/parsers to output the precompiled function. So, by managing that at build time, we can remove the need for most of the library at runtime.

General ideas

  • All formatters/parsers should expose a .toString() function to output itself as a clean string representation. Below, I'm referring to this function as runtime-formatters/runtime-parsers.
  • runtime-formatters/runtime-parsers should not depend on CLDR data. But, it should depend on pre-processed properties only.
  • runtime-formatters/runtime-parsers can reference other functions. Those functions should be packed and distributed as the runtime library for each module. For example, globalize/date.runtime.js, globalize/number.runtime.js, etc.

References

@jzaefferer
Copy link
Contributor

Handlebars also does this pretty well, providing a separate runtime to load with compiled templates. In combination with more-or-less simple requirejs plugins, the whole things can be automated pretty well.

@rxaviers
Copy link
Member Author

Yeap, handlebars is actually the original motivator for messageformat.js as well. I've included its link as another reference. Thanks

@khansrk
Copy link

khansrk commented Mar 4, 2015

hi i'm shahrukh ur idea is good and sounding.Plz tell me how can i contribute in ur project.

@rxaviers
Copy link
Member Author

rxaviers commented Mar 5, 2015

Hi @srk12345, thanks for your interest in contributing to Globalize. A good initial reading is https://github.com/jquery/globalize/blob/master/CONTRIBUTING.md. Then, get yourself familiarized with the contributing workflow by fixing simpler issues, e.g., #393. Then, get familiarized with our source code. If you have any question just let us know.

@khansrk
Copy link

khansrk commented Mar 5, 2015

how can i start my work on plural function for english

@rxaviers
Copy link
Member Author

rxaviers commented Mar 5, 2015

I don't know what you're talking about. This is not about plural function for English. Note I've used a simplified compiled plural function for English in the description as an example of output.

@khansrk
Copy link

khansrk commented Mar 5, 2015

i have understood

@rxaviers
Copy link
Member Author

rxaviers commented Jul 9, 2015

@unindented as a follow up of messageformat/messageformat#112, I'd like to let you know of https://github.com/rxaviers/yarsk/tree/react-globalize. It's react.js specific. But, it's a demonstration on how to use Globalize with webpack (using the work-in-progress runtime implementation being made here). When all this is landed, I hope to have generic Globalize examples to provide. I hope it helps for now.

@unindented
Copy link

@rxaviers This is so good. I'm even using React, so this will be heaven-sent.

Do you have an estimated date when this will be released to npm?

@rxaviers
Copy link
Member Author

rxaviers commented Jul 9, 2015

Awesome! I expect to have peer review on all those pieces (webpack plugins, react-globalize, and this runtime branch). It's hard to estimate a date, but the sooner as time permits :). Your feedback is welcome.

@unindented
Copy link

I'll try to find some time this weekend to really look into it, so that I can provide meaningful feedback.

@rxaviers rxaviers mentioned this issue Jul 23, 2015
1 task
@rxaviers
Copy link
Member Author

For whom is interested on the implementation of this issue, #436 is ready for review.

rxaviers added a commit that referenced this issue Aug 24, 2015
Amends Runtime support (smaller and quicker code for production)
Ref #398
Ref #436
rxaviers added a commit that referenced this issue Aug 27, 2015
ashensis pushed a commit to ashensis/globalize that referenced this issue Mar 17, 2016
…nslations-fix

fix issue with initializing new model in relation using has_many :through which has no translations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants