You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: example rendering performance improvements (#961)
When generating an example in Stackblitz, we have to create a `form` element and submit it to a specific URL. The `form` has to be created eagerly, because some browsers will block us from submitting it if it is created asynchronously.
As a result of this setup we fire off a lot of HTTP requests when an example is rendered which slows the page down a lot. These changes make the following improvements which shave off more than a second of scripting time when transitioning from the "Overview" to "Examples". I've used the datepicker examples as a benchmark.
1. Runs the HTTP requests outside of the Angular zone so that we don't trigger change detections once each request is resolved.
2. Caches the file content so that the user doesn't have to load the same file multiple times.
I've also fixed that the copyright still said "2020".
Copy file name to clipboardExpand all lines: material.angular.io/material.angular.io/material.angular.io/material.angular.io/material.angular.io/src/app/shared/stack-blitz/stack-blitz-button.ts
+19-17Lines changed: 19 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,6 @@ import {StackBlitzWriter} from './stack-blitz-writer';
8
8
@Component({
9
9
selector: 'stack-blitz-button',
10
10
templateUrl: './stack-blitz-button.html',
11
-
providers: [StackBlitzWriter],
12
11
})
13
12
exportclassStackBlitzButton{
14
13
/**
@@ -18,28 +17,31 @@ export class StackBlitzButton {
18
17
* StackBlitz not yet being ready for people with poor network connections or slow devices.
19
18
*/
20
19
isDisabled=false;
21
-
stackBlitzForm: HTMLFormElement|undefined;
22
20
exampleData: ExampleData|undefined;
23
21
24
-
@HostListener('mouseover')onMouseOver(){
25
-
this.isDisabled=!this.stackBlitzForm;
22
+
/**
23
+
* Form used to submit the data to Stackblitz.
24
+
* Important! it needs to be constructed ahead-of-time, because doing so on-demand
25
+
* will cause Firefox to block the submit as a popup, because it didn't happen within
Copy file name to clipboardExpand all lines: material.angular.io/material.angular.io/material.angular.io/material.angular.io/material.angular.io/src/app/shared/stack-blitz/stack-blitz-writer.spec.ts
Copy file name to clipboardExpand all lines: material.angular.io/material.angular.io/material.angular.io/material.angular.io/material.angular.io/src/app/shared/stack-blitz/stack-blitz-writer.ts
0 commit comments