Load style sheets asynchronously?

0

I am building a SPA and there comes a time when I need to insert a new style sheet and remove the old one.

I do not like the solution:

 $('head').append('<link rel="stylesheet" href="new_estyles.css" type="text/css" />');
 $("LINK[href='styles.css']").remove();

Because the page jumps between style sheets that makes it look bad.

Try this solution but it does not work either:

$('#preloader').show();
axios.get('estilos').then(res=>{
    $('head').append('<style>'+ res.data + '</style>');
    $('#preloader').hide();
});
    
asked by Alberto Ortega 05.11.2018 в 23:41
source

0 answers