I've generated SVG spite using icomoon, to provide soft usability I've created a component for it, and realized that this is well enough practice until this time. Some icons just become blank. And I'm still can't find a reason which causes such behavior. I've investigated all issues on Stack Overflow (and not only) and did not find any solution that solves my issue.
I have symbol-defs.svg prefetching in the index.html (size of symbol-defs.svg ~ 200kb):
<link rel="prefetch" href="assets/icon/symbol-defs.svg" as="image" />
As a result, I've got this:
Empty space for most of the icons.
Icon component:
@Component({
selector: 'icon',
templateUrl: './icon.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconComponent {
@Input()
set icon(icon: string) {
this.use = icon ? `${this.location}#${icon}` : '';
}
use: string;
location: string = 'assets/icon/symbol-defs.svg';
}
Icon components HTML:
<svg>
<use [attr.xlink:href]="use" [attr.href]="use"></use>
</svg>
Usage:
<icon icon="finance-service"></icon>
UPDATES:
This issue appears only in prod mode on dev mode it performs well.