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

Add polyfills on demand section to shimming page #1528

Merged
merged 6 commits into from
Aug 25, 2017

Conversation

jeremenichelli
Copy link
Member

@jeremenichelli jeremenichelli commented Aug 16, 2017

Add a short guide about how to load polyfills only when needed to not penalize users on modern browsers.

Resolves #938

@skipjack
Copy link
Collaborator

Beautiful, thanks for starting this @jeremenichelli! I will review in detail this weekend. @TheDutchCoder feel free to review as well. I think we can review, get this merged, then do a follow up pass to synchronize and clean it up. One step closer to knocking down #1258.

Copy link
Collaborator

@skipjack skipjack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremenichelli this looks great. I caught a few minor things but I think we should be able to get this merged soon. Please let me know if you have any questions.

Note that we will have to rework this content a bit when we synchronize it to complete #1258. I think @TheDutchCoder or I can pick that up though as we're already pretty familiar with the rest of the guides. May ping you for review/questions though.


## Loading polyfills on demand

It's really common in web projects to include polyfills in the main bundle. This is not recommended since we are penalizing modern browsers users, since they will have to download a bigger file unnecessarely.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"since" twice in the last sentence is a bit repetitive and "unnecessarely" is spelled wrong. Maybe:

It's really common in web projects to include polyfills in the main bundle. This penalizes modern browser users as they will be forced to download a bigger file containing unneeded polyfills.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremenichelli did you see this comment? I see the other changes but this sentence looks the same and "unnecessarely" is still spelled wrong (except that now it's highlighted 😆 ). Aside from this I think this PR is pretty much good to go, though we will have to rebase to resolve conflicts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol my bad, fixing...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremenichelli no problem, if you could rebase on the latest master branch that would be appreciated as well. If not, I can handle it once you've made this last correction.


### References
* [Reward modern browser users script](https://hackernoon.com/10-things-i-learned-making-the-fastest-site-in-the-world-18a0e1cdf4a7#c665)
* [`useBuiltIns` in `babel-preset-env`](https://github.com/babel/babel-preset-env#usebuiltins)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating this whole section in markdown, use the YAML frontmatter shortcut:

title: ...
sort: ...
contributors:
  - ...
related:
  - title: Reward modern browser users script
     url: https://hackernoon.com/10-things-i-learned-making-the-fastest-site-in-the-world-18a0e1cdf4a7#c665
  - title: ...
     url: ...

This will cause them to pop up in a consistent Further Reading section at the bottom of the page.


### Smaller babel polyfill

`babel-preset-env` uses [browserslist](https://github.com/ai/browserlist) to transpile only what is not supported in your browsers matrix. This preset comes with the `useBuiltIns` option _(false by default)_ which converts your global `babel-polyfill` import to a more granular feature by feature import pattern like:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI build is failing currently because this link is a 404:

https://github.com/ai/browserlist

Was that repo moved?

@jeremenichelli
Copy link
Member Author

jeremenichelli commented Aug 22, 2017

@skipjack I just pushed a fix realted to your first review past.

Regarding the general section clean and rewrite issue, I want to help reviewing not only the section I just wrote but all the page if you think it will help the team, just make sure to tag me as reviewer <3


## Loading polyfills on demand

It's really common in web projects to include polyfills in the main bundle. This is not recommended because we are penalizing modern browsers users since they will download a bigger file **unnecessarely**.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremenichelli Remove 'really', in this sentence it doesn't add anything.

Copy link
Collaborator

@ChrisChinchilla ChrisChinchilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jeremenichelli I'm spending some time with the webpack docs and polishing the language we use, so here are few small comments and suggestions.

Thanks for your time :)

@jeremenichelli
Copy link
Member Author

@ChrisChinchilla thanks for the feedback :) just pushed changes regarding your suggestion.

@jeremenichelli jeremenichelli force-pushed the guides/polyfills branch 2 times, most recently from 98ee977 to 65c8112 Compare August 24, 2017 18:36
@jeremenichelli
Copy link
Member Author

@skipjack I fixed the initial paragraph ending, go checkout it out and tell me if you like it. Also, I tried to rebase but I got a weird .json files on the diff so I rolled back, let me know if that's an issue for merging.

@skipjack
Copy link
Collaborator

I fixed the initial paragraph ending, go checkout it out and tell me if you like it. Also, I tried to rebase but I got a weird .json files on the diff so I rolled back, let me know if that's an issue for merging.

@jeremenichelli looks great thanks. Yeah those .json files are to be expected because they were .gitignored prior to #1490 so they pop as new files when you rebase. Don't worry about it I'll take care of the rebase and get this merged tonight.

@skipjack skipjack removed the request for review from TheDutchCoder August 24, 2017 22:27
@jeremenichelli
Copy link
Member Author

Awesome @skipjack, feel free to tag me on the PR for Guides section cleaning, more than willing review/help.

@skipjack skipjack merged commit f2782aa into webpack:master Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants