404 code checker for background image, if 404 - replace with original and crop with nginx. I resize images and add new size to filename (original: 'funny_cat.jpg', resized: 'funny_cat_320_320.jpg'). If resize script haven't finished, checker replace 404 image with original and crop by nginx. What did i miss? Is code understandable enough? declare const jQuery: any;class Checker404IndexImages {    allDivsWithBackgroundImageSelector = .container div.with-bg-image:not([data-processed]);    allElements: NodeListOf<Element>;    constructor() {    }    private initElems(): void {        this.allElements = document.querySelectorAll(this.allDivsWithBackgroundImageSelector);    }    private getUrlFromBackgroundImage(backgroundImage: string): string {        return backgroundImage.slice(5, -2);    }    private getSourceFromUrl(url: string): string {        const splitted = url.split('.');        const ext = splitted[splitted.length-1];        const filename = splitted.slice(0, -1).join('');        return filename.split('_')[0] + '.' + ext;    }    private getWidthFromUrl(url: string): string {        return url.split('.')[0].split('_').slice(-2).join('_').split('_')[0];    }    private getHeightFromUrl(url: string): string {        return url.split('.')[0].split('_').slice(-2).join('_').split('_')[1];    }    private processElems(): void {        [].forEach.call(this.allElements, el => {            const url = this.getUrlFromBackgroundImage(el.style.backgroundImage);            const sourceUrl = this.getSourceFromUrl(url);            const width = this.getWidthFromUrl(url);            const height = this.getHeightFromUrl(url);            //console.log(url, sourceUrl, width, height);            jQuery.ajax({                url: url,                type: 'HEAD',                success: answer => null,//console.log('success answer:', answer),                error: err => {                    //console.log('error answer:', err);                    if (404 === err.status) {                        el.style.backgroundImage = `url('${sourceUrl}?crop=1&w=${width}&h=${height}')`;                        el.setAttribute('data-processed', '');                    }                }            });        });    }    public checkAllImagesExceptProcessedAndReplaceWithSourceIfNeeded(): void {        this.initElems();        this.processElems();    }}export default Checker404IndexImages;and usage:const checker404IndexImages = new Checker404IndexImages();checker404IndexImages.checkAllImagesExceptProcessedAndReplaceWithSourceIfNeeded();
Background image checker for 404 error, typescript
jquery;image;http;typescript