link element onload

前端 未结 11 857
予麋鹿
予麋鹿 2020-11-30 03:31

Is there anyway to listen to the onload event for a element?

F.ex:

var link = document.createElement(\'link\');
link.rel =          


        
11条回答
  •  野性不改
    2020-11-30 04:10

    Since you didn't like my hack :) I looked around for some other way and found one by brothercake.

    Basically, what is suggested is to get the CSS using AJAX to make the browser cache it and then treat the link load as instantaneous, since the CSS is cached. This will probably not work every single time (since some browsers may have cache turned off, for example), but almost always.

提交回复
热议问题