How to load up CSS files using Javascript?

后端 未结 19 3298
栀梦
栀梦 2020-11-21 07:51

Is it possible to import css stylesheets into a html page using Javascript? If so, how can it be done?

P.S the javascript will be hosted on my site, but I want users

19条回答
  •  遇见更好的自我
    2020-11-21 07:56

    I'd like to share one more way to load not only css but all the assets (js, css, images) and handle onload event for the bunch of files. It's async-assets-loader. See the example below:

    
     
    

    According to the async-assets-loader docs

提交回复
热议问题