Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylesheet attempts to load img? #3

Open
TheDigitalOrchard opened this issue Oct 14, 2019 · 1 comment
Open

Stylesheet attempts to load img? #3

TheDigitalOrchard opened this issue Oct 14, 2019 · 1 comment

Comments

@TheDigitalOrchard
Copy link

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.

@adaniello
Copy link

adaniello commented Sep 7, 2020

Answer is #2 but it's your! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants