linuxyamigos

Untitled

Jan 27th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function assets(filename){
  2.     load = filename.match(/^\/\//) || filename.match(/^http:/) || filename.match(/^https:/) ? filename : 'assets/' + filename;
  3.  
  4.     if (filename.match(/\.js$/)){
  5.         var fileref=document.createElement('script')
  6.         fileref.setAttribute("type","text/javascript")
  7.         fileref.setAttribute("src", load)
  8.     }
  9.     else if (filename.match(/\.css$/)){
  10.         var fileref=document.createElement("link")
  11.         fileref.setAttribute("rel", "stylesheet")
  12.         fileref.setAttribute("type", "text/css")
  13.         fileref.setAttribute("href", load)
  14.     }
  15.     if (typeof fileref!="undefined")
  16.         document.getElementsByTagName("head")[0].appendChild(fileref)
  17. }
Add Comment
Please, Sign In to add comment