JavaScript
Article

jQuery add stylesheet if not loaded

By Sam Deering

Code snippet quicky. Use jQuery to add a setylesheet if it’s not already loaded.

var cssUrl = 'css/style.css';
if($('link[rel*=style][href="'+cssUrl+'"]').length==0)
{
    $("head").append('');
}
Recommended
Sponsors
Get the latest in JavaScript, once a week, for free.