사용자:하늘/참고/CDN: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
 
(사용자 2명의 중간 판 10개는 보이지 않습니다)
1번째 줄: 1번째 줄:
<onlyinclude><span class="{{#switch:{{{1|}}}
== github => jsdelivr ==
|성공 = success
https://stackoverflow.com/questions/17341122/link-and-execute-external-javascript-file-hosted-on-github
|경고 = warning
|error}}">{{#if:{{{2|}}}|{{{2}}}|{{#switch:{{{1|}}}
|성공 = 성공
|경고 = 경고
|에러}}}}</span></onlyinclude>


<code><nowiki>{{상태|성공|성공메시지}}</nowiki></code>
There ''is'' a good workaround for this, now, by using jsdelivr.net.
{{ {{FULLPAGENAME}}|성공|성공메시지}}


<code><nowiki>{{상태|경고|경고메시지}}</nowiki></code>
'''Steps''':
{{ {{FULLPAGENAME}}|경고|경고메시지}}


<code><nowiki>{{상태||에러메시지}}</nowiki></code>
# Find your link on GitHub, and click to the "Raw" version.
{{ {{FULLPAGENAME}}||에러메시지}}
# Copy the URL.
# Change <code>raw.githubusercontent.com</code> to <code>cdn.jsdelivr.net</code>
# Insert <code>/gh/</code> before your username.
# Remove the <code>branch</code> name.
# (Optional) Insert the ''version'' you want to link to, as <code>@version</code> (if you do not do this, you will get the ''latest'' - which may cause long-term caching)


이 틀은 일관성있는 디자인, 변경사항이 있을때 틀 수정으로 일괄적용 시키기 위한 틀입니다. <nowiki><span class="error"></span></nowiki>을 이용하셔도 됩니다.
----'''Examples''':
<code><nowiki>http://raw.githubusercontent.com/</nowiki><username>/<repo>/<branch>/path/to/file.js</code>
Use this URL to get the latest version:
<code><nowiki>http://cdn.jsdelivr.net/gh/</nowiki><username>/<repo>/path/to/file.js</code>
Use this URL to get a specific version or commit hash:
<code><nowiki>http://cdn.jsdelivr.net/gh/</nowiki><username>/<repo>@<version or hash>/path/to/file.js</code>
'''For production environments''', consider targeting a specific tag or commit-hash rather than the branch. Using the ''latest'' link may result in long-term caching of the file, causing your link to not be updated as you push new versions. Linking to a file by commit-hash or tag makes the link unique to version.
----'''Why is this needed?'''


<!--[[분류:상태 틀]]-->
In 2013, GitHub started using <code>X-Content-Type-Options: nosniff</code>, which instructs more modern browsers to enforce strict MIME type checking. It then returns the raw files in a MIME type returned by the server, preventing the browser from using the file as-intended (if the browser honors the setting).

2023년 12월 31일 (일) 01:22 기준 최신판

github => jsdelivr[편집 | 원본 편집]

https://stackoverflow.com/questions/17341122/link-and-execute-external-javascript-file-hosted-on-github

There is a good workaround for this, now, by using jsdelivr.net.

Steps:

  1. Find your link on GitHub, and click to the "Raw" version.
  2. Copy the URL.
  3. Change raw.githubusercontent.com to cdn.jsdelivr.net
  4. Insert /gh/ before your username.
  5. Remove the branch name.
  6. (Optional) Insert the version you want to link to, as @version (if you do not do this, you will get the latest - which may cause long-term caching)

Examples:

http://raw.githubusercontent.com/<username>/<repo>/<branch>/path/to/file.js

Use this URL to get the latest version:

http://cdn.jsdelivr.net/gh/<username>/<repo>/path/to/file.js

Use this URL to get a specific version or commit hash:

http://cdn.jsdelivr.net/gh/<username>/<repo>@<version or hash>/path/to/file.js

For production environments, consider targeting a specific tag or commit-hash rather than the branch. Using the latest link may result in long-term caching of the file, causing your link to not be updated as you push new versions. Linking to a file by commit-hash or tag makes the link unique to version.


Why is this needed?

In 2013, GitHub started using X-Content-Type-Options: nosniff, which instructs more modern browsers to enforce strict MIME type checking. It then returns the raw files in a MIME type returned by the server, preventing the browser from using the file as-intended (if the browser honors the setting).