I load css
var ss = document.createElement("link");
var url = 'http://site.ru/style.css';
ss.setAttribute("rel", "stylesheet");
ss.setAttribute("type", "text/css");
ss.setAttribute("href", url);
document.getElementsByTagName("head")[0].appendChild(ss);
I want to call function after css loading, but tag link hasn’t onload event, is there a way to do it?
You currently don’t load that css stuff via Ajax, but you could do it. That way, you also have your callback when data transfer has finished. I’m using jQuery in this example to make things short and convinient.
Be aware: This only works if your javascript & your css files are located on the same domain.
Simplified vanilla Javascript might look like: