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

Only serve transpiled assets for old browsers #479

Closed
balloob opened this issue Oct 26, 2017 · 6 comments
Closed

Only serve transpiled assets for old browsers #479

balloob opened this issue Oct 26, 2017 · 6 comments
Labels
Performance Affects the performance of the UI

Comments

@balloob
Copy link
Member

balloob commented Oct 26, 2017

Transpiled code is obfuscating the intention of our JavaScript code. This leads to a bigger file size and to JavaScript engines not being able to optimize as much.

Approach taken from https://philipwalton.com/articles/deploying-es2015-code-in-production-today/ (found it via talk from Chrome Dev Summit)

<!-- Browsers with ES module support load this file. -->
<script type="module" src="main.js"></script>

<!-- Older browsers load this file (and module-supporting -->
<!-- browsers know *not* to load this file). -->
<script nomodule src="main-legacy.js"></script>

For frontend.html, this saves us almost 100kb !

File sizes with transpilation:

image

image

File sizes without transpilation

image

image

@balloob
Copy link
Member Author

balloob commented Oct 26, 2017

Note, minification was done with babel-preset-minify because uglifyjs doesn't support ES2015. Running that preset on transpiled code will result in bigger files than uglifyjs:

Transpiled and minified with babel-preset-minify

image

image

@balloob balloob added the Performance Affects the performance of the UI label Oct 26, 2017
@balloob
Copy link
Member Author

balloob commented Oct 26, 2017

When we start to distinguish between transpiled / not transpiled, it will also be easy to start adding polyfills by default to the transpiled version but keeping the ES2015 version lean.

@andrey-git
Copy link
Contributor

There is uglify-es for es6
The article says to special-case Safari10

@andrey-git
Copy link
Contributor

Btw according to caniuse - type="module" is not supported by FF: http://caniuse.com/#feat=es6-module
Maybe use a traditional useragent-based approach?

@balloob
Copy link
Member Author

balloob commented Oct 27, 2017

Yeah I would be fine with that too.

@balloob
Copy link
Member Author

balloob commented Jun 7, 2018

This has been implemented by Andrey.

@balloob balloob closed this as completed Jun 7, 2018
tkdrob pushed a commit to tkdrob/frontend that referenced this issue Apr 20, 2021
Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) and [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom). These dependencies needed to be updated together.

Updates `react` from 17.0.1 to 17.0.2
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v17.0.2/packages/react)

Updates `react-dom` from 17.0.1 to 17.0.2
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v17.0.2/packages/react-dom)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Performance Affects the performance of the UI
Projects
None yet
Development

No branches or pull requests

2 participants