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

Combine multiple injects #10

Open
Nemo64 opened this issue Jul 26, 2014 · 1 comment
Open

Combine multiple injects #10

Nemo64 opened this issue Jul 26, 2014 · 1 comment

Comments

@Nemo64
Copy link
Contributor

Nemo64 commented Jul 26, 2014

Just as an idea, if multiple packages inject stuff into the app there are multiple script tags. Alone my translator package injects 2 things and because of that there are 2 script tags.
This also pollutes the global id namespace.

<script id='translator-namespaces' type='application/ejson'>{"both/l10n/public":{"de_DE":1,"en_US":1}}</script>
<script id='translator-language' type='application/ejson'>{"$type":"Translator.LanguageArray","$value":"de_DE de en_US en"}</script>

I just thought if it would be possible to combine all object injects into one with an id that is long enough to not interfere with other id's.

<script id='inject-initial' type='application/ejson'>{
"translator-namespaces":{"both/l10n/public":{"de_DE":1,"en_US":1}},
"translator-language":{"$type":"Translator.LanguageArray","$value":"de_DE de en_US en"}}
</script>
@gadicc
Copy link
Contributor

gadicc commented Mar 7, 2016

Sorry for the late reply :)

Instead of:

Inject.obj('translator-namespaces', {...});
Inject.obj('translator-language', {...});

Can't you just:

Inject.obj('translator', {
  namespaces: ...
  language: ...
});

Yeah, it could be nice to save on the bytes for cases where multiple / different packages are all using it. I do think though that it's quite nice to so clearly see where all the data comes from, but I guess in production the speed is more important. So yes, this is definitely something we can consider.

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

2 participants