是的,您可以,借助 unpkg 和 jsDelivr 等流行 CDN!
Unpkg 和 jsDelivr 是托管公共 npm 包的 CDN。它们允许基于浏览器的应用程序在全球范围内快速访问包,而无需包管理器或捆绑器。
{ "name": "@monaco-editor/react", "version": "4.4.6", "main": "lib/cjs/index.js", "unpkg": "lib/umd/monaco-react.min.js", "jsdelivr": "lib/umd/monaco-react.min.js" }
unpkg 和 jsdelivr 是自定义字段,而不是标准字段,这些可以被其他工具忽略,除非它们明确识别它们。它用于确定当通过 CDN unpkg / jsdelivr 请求包时要提供哪个文件。
示例:
<script src="https://unpkg.com/@monaco-editor/react@latest/dist/monaco-react.min.js"></script>
相关性:
示例:
{ "name": "@monaco-editor/react", "version": "4.4.6", "main": "lib/cjs/index.js", "unpkg": "lib/umd/monaco-react.min.js", "jsdelivr": "lib/umd/monaco-react.min.js" }
相关性:
示例:
<script src="https://unpkg.com/@monaco-editor/react@latest/dist/monaco-react.min.js"></script>
相关性:
示例:
<script src="https://cdn.jsdelivr.net/npm/my-library"></script>
相关性:
示例:
{ "name": "@monaco-editor/react", "version": "4.4.6", "main": "lib/cjs/index.js", "unpkg": "lib/umd/monaco-react.min.js", "jsdelivr": "lib/umd/monaco-react.min.js" }
相关性:
示例:
<script src="https://unpkg.com/@monaco-editor/react@latest/dist/monaco-react.min.js"></script>
相关性:
Use Case | Ideal For | Example Usage |
---|---|---|
Browser Inclusion | Simplicity | |
Fast Delivery | High-traffic apps | Use of jsDelivr or Unpkg for caching |
Avoiding Build Steps | Prototypes or small projects | UMD or IIFE pre-bundled files |
Embedding in Static Sites | Blogs, lightweight sites | Markdown renderer, chart libraries |
Demos and Sandboxes | Quick testing | Platforms like CodePen or JSFiddle |
Sharing Across Frameworks | Multi-framework apps | Shared libraries or design systems |
CDN 托管是对 npm 分发的一个很好的补充,特别是对于以 Web 为中心的库。如果您有具体要求,请随时询问!
以上是访问包而不安装它。的详细内容。更多信息请关注PHP中文网其他相关文章!