Link and execute external JavaScript file hosted on GitHub

前端 未结 15 1064
感动是毒
感动是毒 2020-11-22 04:08

When I try to change the linked reference of a local JavaScript file to a GitHub raw version my test file stops working. The error is:

Refused to exe

15条回答
  •  Happy的楠姐
    2020-11-22 04:33

    Alternatively, if generating your markup server-side, you can just fetch and inject. For example, in JSTL you could do this:

    
    

    They don't allow hotlinking for a reason, so probably bad form if you want to be a good citizen. I'd suggest you cache that javascript and only actually re-fetch periodically as you see fit.

提交回复
热议问题