Execute External JavaScript from GitHub Despite MIME Error
When attempting to reference a local JavaScript file from GitHub's raw version, users may encounter an error. This arises from GitHub's use of X-Content-Type-Options: nosniff, which enforces strict MIME type checking. As a result, the linked script becomes unusable.
Fortunately, jsdelivr.net offers a simple workaround. By employing a specific set of modifications to the GitHub URL, users can seamlessly load external JavaScript.
Procedure:
Examples:
Latest version:
http://cdn.jsdelivr.net/gh/<username>/<repo>/path/to/file.js
Specific version or commit hash:
http://cdn.jsdelivr.net/gh/<username>/<repo>@<version or hash>/path/to/file.js
Considerations:
The above is the detailed content of How Can I Execute External JavaScript from GitHub Despite MIME Errors?. For more information, please follow other related articles on the PHP Chinese website!