css - Loop won't finish executing when a function is called within - JavaScript -


i using function below create , link stylesheet in <head> tag depending on url passed.

function create(file) {     var link = document.createelement("link");     link.href = "https://example.com/" + file;     link.rel = "stylesheet";     document.head.appendchild(link); }     

i have loop won't stop running whenever function called.

    for(i=0; i<array.length; i++){           thefile = array[i];           create(thefile);     } 

within array list of css files - "bootstrap.min.css", "font-awesome.min.css"

i have tested out function on own , seems work fine:

create("style.css");   create("style.css"); 

the code above manages create 2 stylesheets in <head> tag.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -