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('<link rel="stylesheet" type="text/css" href="'+cssUrl+'"/>');
}
Sam Deering Sam Deering
Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.

No Reader comments

Stay ahead of the game Exclusive content for developers and digital experts Go Premium