简体   繁体   中英

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). Is there a way to serve a javascript file instead of index.html when someone access my github pages url? Or alternatively is there a way such that index.html returns a javascript file as response instead of the usual html content?

I think you can use the "raw" version link of the file. You get this link when you click on the "RAW" button.

Example:

GitHub File:

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. This is a good option for single files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM