-
Notifications
You must be signed in to change notification settings - Fork 12k
Angular 8 Polyfills ES2015 Bundle Javascript Execution Time is very high - Google Pagespeed shows warning #14871
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
Comments
@naveedahmed1, which are the polyfills that you have defined in polyfills.ts? |
Here's my `/** IE9, IE10 and IE11 requires all of the following polyfills. **/ /** IE10 and IE11 requires the following for the Reflect API. */ /** Evergreen browsers require these. **/ import 'zone.js/dist/zone'; // Included with Angular CLI. /***************************************************************************************************
import 'hammerjs'; import { polyfill } from 'smoothscroll-polyfill'; |
None of these are required to be manually imported with 8.0+:
The two reflect imports are also only needed if the project directly uses the
|
@clydin I removed these imports and it reduced the JavaScript Execution time from 4.6s to 3.4s and Main thread work from 6.5s to 4.9s. I think its still a lot. Can you please confirm if below import is necessary or can we remove that as well?
|
Hi, zone.js is needed.
…On Tue, 25 Jun 2019 at 13:20, Naveed Ahmed ***@***.***> wrote:
@clydin <https://github.com/clydin> I removed these imports and it
reduced the JavaScript Execution time from 4.6s to 3.4s and Main thread
work from 6.5s to 4.9s.
I think its still a lot.
Can you please confirm if below import is necessary or can we remove that
as well?
import 'zone.js/dist/zone';
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#14871?email_source=notifications&email_token=AEF74WXGYHHOC2OBTTBW7D3P4H5Q7A5CNFSM4H26UIJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYP42NY#issuecomment-505400631>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEF74WVGM5RZCTVR7OHS6DLP4H5Q7ANCNFSM4H26UIJA>
.
|
@alan-agius4 what else could be causing the issue? Lighthouse show errors "Reduce JavaScript execution time" and "Minimize main-thread work". |
I'm not familiar with the last one, however ( Can you try commenting out each one (probably one at a time) to see if that has any effect? |
Edit: Fixes got merged 🎉 |
@clydin I have removed everything and now only have |
@naveedahmed1 did you deploy your web app publicly? I can try to have a look and profile to see what's wrong. |
@mgechev yes its available at https://www.mustakbil.com/ |
There is way to much javascript in main.js (1,9 MB). By glossing over https://www.mustakbil.com/main-es2015.6fa4605db52f9bbfb86f.js it seems like you use moment.js and bundle all locales with it (thats ~400kb). You have to configure webpack to pick only the locales you need, like described in https://github.com/jmblog/how-to-optimize-momentjs-with-webpack. Or you switch to something like https://github.com/iamkun/dayjs thats way leaner by default and has a similar syntax to moment. Then there seems to be a lot of material design. Be sure to only include the modules you really use. If you use angular-cli, you can inspect the composition of your bundles & chunks. A good way to see if there is to much bundled with the app. You can do that from the commandline with: # generates a stats json file along with your build
ng build --prod --aot --stats-json
# opens a page in your browser to visualize bundle composition:
npx webpack-bundle-analyzer dist/*/stats-es2015.json |
On the landingpage https://www.mustakbil.com/ you have an incredible amount of force reflows. If you do a profiling via chrome in the web inspector performance tab, and you see this: It's the lazy loaded images in the job cards, that fade in upon scroll. You might wanna change the code so it doesn't do the visiblity check right after it got put into the dom. We on our page batch those things up and process them after a single setTimeout to avoid any force reflows. |
On https://www.mustakbil.com/employers the 3 boxes on the top left seems to need an incredible amount of computation: If you profile it, it looks like 70% of CPU is spend there: It may have to do with how the material design |
I think (but have not verified) that I know why the It's not the polyfills themselves that are spending so much time, but rather that there is a lot of time spent in inside zone.js calls. Since zone.js is imported in polyfills, the time is logged as spent there. This is similar to how stack traces for some errors show up from polyfills as well, and then you have to check the whole stack trace to figure out in what component the error came from. Which is to say, I think the Also, I think that removing a given volume of code shouldn't ever affect Which is to say, it looks like your code is doing a lot of work. This is similar to what @sod found. You can validate this by commenting out your bootstrap code in |
@sod, @filipesilva, thanks for looking into that :) @naveedahmed1, you should be able to take it from here. Doesn't seem like a CLI issue. Let us know how it goes! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Is this a regression?
Yes, the previous version in which this bug was not present was: 7.xDescription
After upgrading to Angular 8, the Google Pagespeed score of my website has been decreased.
One of the warning Pagespeed displays is
Reduce JavaScript execution time
, which is 4.6 seconds. Its surprising that most of the script execution time is for the "Angular Polyfills ES2015 Javascript bundle" which is 3.8 seconds.Another warning it shows is "Minimize main-thread work" which is 6.5 s and I think its also due to the polyfills bundle.
🔬 Minimal Reproduction
Check Pagespeed score for any Angular website with SSR enabled and notice the warnings for the Mobile devices.
🔥 Exception or Error
🌍 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: