How can I make my css files asynchronous?
// create a link tag
var link = document.createElement( "link" );
link.rel = "stylesheet";
link.href = "main.css";
And then call a async function that inserts this link tag.
async=true for css link tag
I don't think that will work.
But We can do that using JS:
var resource = document.createElement('link');
resource.setAttribute("rel", "stylesheet");
resource.setAttribute("href","path/to/cssfile.css");
resource.setAttribute("type","text/css");
var head = document.getElementsByTagName('head')[0];
head.appendChild(resource);
I think
That it'll achieve what you're trying to do.
If you don't want javascript
have a look at: How to load CSS asynchronously without using JavaScript?
Hope it'll help.
How to asynchronously load CSS using jQuery?
This should work in IE:
$("head").append("<link rel='stylesheet' type='text/css' href='/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css' />");
Related Topics
How to Make Content Appear Beneath a Fixed Div Element
How to Use the Matrix Transform and Other Transform CSS Properties
Simulating Border-Collapse in Lists (No Tables)
Multiple CSS Keyframe Animations Using Transform Property Not Working
Vertically Center Content of Floating Div
Can't Change CSS Style in Angularjs
How to Prevent the Background Image from Getting Blurry
CSS Div Width Percentage and Padding Without Breaking Layout
Display:None VS Visibility:Hidden VS Text-Indent:9999 How Screen Reader Behave with Each One
Are There Any Practical Reasons to Use "Em" Instead of "Pt" Font Size Units
How to Add Space Between Elements So They Fill Their Container Div
Does IE9 Not Support Display: Inline-Flex at All
Css: How to Get Scrollbars for Div Inside Container of Fixed Height