简体   繁体   English

我可以在github页面站点中提供一个javascript文件而不是index.html吗?

[英]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.

相关问题 Github 页面抛出 404 'Not Found' 错误但站点在测试 index.html 文件时在浏览器中工作 - Github Pages throwing 404 'Not Found' Error but Site works when testing index.html file in browser 我的Javascript Ajax请求可在Phonegap index.html中使用,但不能在其他任何页面中使用,如何解决此问题? - My Javascript Ajax request works in Phonegap index.html but not in any other pages, how can I fix this? 为什么更改我的serve方法会破坏我的index.html文件? - Why does chaning my serve method break my index.html file? 如何使用 JavaScript 在我的 index.html 文件中嵌入 API 调用? - How do I embed an API call in my index.html file using JavaScript? 当我将 javascript 文件添加到 index.html 时,数据未在我的数据库中重新编码 - Data isnt recode in my database when i add javascript file to the index.html 如何在 React 的 index.html 文件中正确包含 css 文件? - How can I properly include a css file in my index.html file in React? 每当我使用 `npm start` 启动我的应用程序时,它都会将我带到 Rails 主屏幕上的 Ruby 而不是我的 index.html 文件 - Whenever I start my app using `npm start` it brings me to the Ruby on Rails Homescreen instead of my index.html file 如何使用gulp-inject将文件的内容插入到index.html中? - How can I insert the contents of a file in my index.html with gulp-inject? Github 实时预览 readme 而不是 /dist/ 文件夹中的 index.html - Github live previews readme instead of index.html in the /dist/ folder 如何在 Javascript 中的另一个 index.html 网页中以文本格式而不是 URL 显示对象属性? - How can I display the object property in text format inside the another index.html webpage in Javascript instead of an URL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM