[英]Can I serve a javascript file instead of index.html in my github pages site?
I want to serve a javascript file using github pages because using a CDN is too slow (it doesn't update immediately when there is a new version of the file). 我想使用github页面提供一个javascript文件,因为使用CDN太慢了(当有新版本的文件时,它不会立即更新)。 Is there a way to serve a javascript file instead of index.html when someone access my github pages url?
当有人访问我的github页面url时,是否有一种方法可以提供javascript文件而不是index.html? Or alternatively is there a way such that index.html returns a javascript file as response instead of the usual html content?
或者,是否有一种方法使index.html返回一个javascript文件作为响应,而不是通常的html内容?
I think you can use the "raw" version link of the file. 我认为您可以使用文件的“原始”版本链接。 You get this link when you click on the "RAW" button.
当您单击“ RAW”按钮时,将获得此链接。
Example: 例:
GitHub File: GitHub文件:
https://github.com/jquery/jquery/blob/master/src/core.js
Raw Link: 原始链接:
https://raw.githubusercontent.com/jquery/jquery/master/src/core.js
You can also use a Github Gist version. 您也可以使用Github Gist版本。 This is a good option for single files.
对于单个文件,这是一个不错的选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.