title: AngularJS + Angular Elements Performance
body: <p>I'm working on a very old website which is using AngularJS. The plan is to migrate it slowly to Angular, however it will be very long process. As it's not a SPA but rather Website with some AngularJS Controllers, I decided to use Angular Elements. In this way I can replace Component by Component (Or rather Controller to Component).</p>
  
  <p>There are some pages where non of the new Angular Elements are available but the scripts is part of the main js bundle. Based on the Lighthouse Performance review (I'm using Chrome Extension of Lighthouse) the website Performance is really bad and I'm trying to improve it. However there are many scripts and the Execution time is just ridiculous.</p>
  
  <p>Anyway let's come back to the source of my question. As I mentioned there are some pages where non Angular Elements are available but the scripts for them is on the page. On those pages I'm getting performance around 30-38 with Lighthouse. If I remove the Angular bundle (runtime.js, main.js and scripts.js)(I'm leaving the polyfills.js) the Performance is jumping to 48. Which is a huge difference. Especially when non of those scripts have to be executed.</p>
  
  <p>From the Lighthouse report with all scripts I can see that <code>polyfill.js</code> is taking a lot of time to execute. After some research (<a href="https://github.com/angular/angular-cli/issues/14871#issuecomment-510554929" rel="nofollow noreferrer">angular-cli polyfill bundle issue</a>) I found that the reason why it showing it as <strong>polyfill</strong> is because of <strong>zone.js</strong>. But why the hell after removing the Angular scripts(runtime.js, main.js and scripts.js) I'm not getting the same outcome when the <strong>polyfills</strong> and <strong>zone.js</strong> are still on the page?</p>
  
  <p>Wanted to check if anyone else have experience similar issue and if you have suggestions what can I do to improve it?</p>
  
  <p>Result without Angular bundle:
  <a href="https://i.stack.imgur.com/IYS5K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IYS5K.png" alt="enter image description here"></a></p>
  
  <p>Result with Angular bundle:
  <a href="https://i.stack.imgur.com/l5eI4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l5eI4.png" alt="enter image description here"></a></p>