Assets.js icon indicating copy to clipboard operation
Assets.js copied to clipboard

Stylesheet attempts to load img?

Open TheDigitalOrchard opened this issue 5 years ago • 1 comments

I recently incorporated this library into my framework, and it works great! Thanks!

But I'm curious why it attempts to load CSS files as an "img" first?

getCss: function(url, callback){
            var d         = $.Deferred(),
                link      = document.createElement('link');
                link.type = 'text/css';
                link.rel  = 'stylesheet';
                link.href = url;

            document.getElementsByTagName('head')[0].appendChild(link);

            var img = document.createElement('img');
                img.onerror = function(){
                    d.resolve();
                    if(callback) callback(link);
                };
                img.src = url;

            return d.promise();
        }

What is the purpose of that? It's always failing in my browser.

TheDigitalOrchard avatar Oct 14 '19 01:10 TheDigitalOrchard

Answer is https://github.com/aheinze/Assets.js/issues/2 but it's your! :)

adaniello avatar Sep 07 '20 15:09 adaniello