Check if asset exists


#1

Is there any way to check if an asset exists? My theme is built with webpack, which is configured to extract css only in production (meaning my style.css only exists in production but not during development).

Any ideas? Thanks!


#2

Could you use javascript to do this? Something like:

$.get(css_url)
    .done(function() { 
        // load the css file or whatever
    }).fail(function() { 
        // not exists code
    })