Priority hints indicate the relative priority of resources to the browser. They can enable optimal loading and improve Core Web Vitals.
From https://web.dev/priority-hints/
example with fetch API:
<script>
fetch('https://example.com/', {priority: 'low'})
.then(data => {
// Trigger a low priority fetch
});
</script>
how set "priority" to Angular HttpClient?
I have tried to force a priority setting:
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<button (click)="makeRequest()">make request</button><br />
<pre>{{ data | json }}</pre>`,
})
export class AppComponent implements OnInit {
data: any;
constructor(private httpClient: HttpClient) {}
ngOnInit(): void {
this.makeRequest();
}
makeRequest() {
this.data = null;
this.httpClient
.get('https://jsonplaceholder.typicode.com/todos/1', {
priority: 'low',
} as any)
.subscribe((result) => (this.data = result));
}
}
but doesn't works... priority is always hight
also suggested to angular team https://github.com/angular/angular/issues/45426
You can use like below:
this.http.get<YourConfig>(this.yourConfigUrl, {priority: 'low'});