Google Hosted Libraries היא רשת להפצת תוכן יציבה, מהירה וזמינה ברחבי העולם, שמספקת את ספריות ה-JavaScript הפופולריות ביותר בקוד פתוח.
Google עובדת ישירות עם בעלי העניין המרכזיים בכל פרויקט של ספרייה, ומקבלת את הגרסאות העדכניות ביותר ברגע שהן פורסמות.
ספריות
כדי לטעון ספרייה מתארחת, מעתיקים את קטע ה-HTML של הספרייה (שמוצג בהמשך) ומדביקים אותו בדף האינטרנט. לדוגמה, כדי לטעון את jQuery, מטמיעים את קטע הקוד <script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
בדף האינטרנט.
מומלץ לטעון ספריות מה-CDN דרך HTTPS, גם אם באתר שלכם נעשה שימוש רק ב-HTTP. כיום הביצועים מהירים, והאחסון במטמון פועל באותה יעילות. הקבצים של ה-CDN מוצגים עם כותרות CORS ו-Timing-Allow, ומותר לשמור אותם במטמון למשך שנה.
Bootstrap
- קטע קוד:
-
<script src="https://ajax.googleapis.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.min.js"></script>
- site:
- github.com/twbs/bootstrap
- גרסאות:
- 5.3.3
CesiumJS
- 摘要:
-
<script src="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.78/Build/Cesium/Cesium.js"></script>
- site:
- github.com/CesiumGS/cesium
- 版本:
- 1.78
D3.js
- 代码段:
-
<script src="https://ajax.googleapis.com/ajax/libs/d3js/7.9.0/d3.min.js"></script>
- site:
- d3js.org
- versions:
-
7.9.0、7.8.5、7.8.4、7.8.3、7.8.2、7.8.1、7.8.0、7.7.0、7.6.1、7.4.2、7.0.0、6..6.5、6.6.5、6.6.5、6.6.5、6.6.5、6.6.5、6.6.5、6.6.5、6.6.1、7.8.1、7.8.1、7.8.0、7.7.0、7.6.1、7.4.2、7.0.5、6.6.1、6.6.
Dojo
- 摘要:
-
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.13.0/dojo/dojo.js"></script>
- site:
- dojo Toolkit.org
- 版本: 。
- snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/ext-core/3.1.0/ext-core.js"></script>
- site:
- sencha.com/products/extcore
- גרסאות:
- 3.1.0, 3.0.0
- 摘要:
-
<script src="https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js"></script>
- site:
- hammerjs.github.io
- 版本:
- 2.0.8
- snippet:
-
<script type="module">
import { IndefiniteObservable } from "https://ajax.googleapis.com/ajax/libs/indefinite-observable/2.0.1/indefinite-observable.bundle.js";
</script> - site:
- https://github.com/material-motion/indefinite-observable-js
- גרסאות:
- 2.0.1, 1.0.1
- 3.x 代码段:
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
- 2.x 代码段:
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
- 1.x 代码段:
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
- site:
- jquery.com
- 版本:
- . .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1 .1、.1 .1、.1、.1、.1、.1、3、3、3、3.0、3.6.1、3.6.0、3.5.1、3.5.0、3.4.1、3.4.1、3.2,
- 注意:
- 3.3.0、2.1.2、1.2.5 和 1.2.4 未托管,因为它们的野生生活短而不稳定。
- snippet:
-
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script> - site:
- jquerymobile.com
- גרסאות:
- 1.4.5, 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0
- הערה:
- הספרייה הזו תלויה ב-jQuery. כמו כן, עליך לטעון את jQuery לפני טעינת המודול הזה.
- קטע קוד:
-
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.14.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.14.1/jquery-ui.min.js"></script> - site:
- jqueryui.com
- גרסאות:
- 1.14.1, 1.14.0, 1.13.3, 1.13.2, 1.13.1, 1.13.0, 1.12.1, 1.12.0, 1.11.4, 1.11.3, 1.11.2, 1.11.1, 1.11.0, 1.10.4, 1.10.3, 1.10.2, 1.10.1, 1.10.0, 1.9.2, 1.9.1, 1.9.0, 1.8.24, 1.8.23, 1.8.22, 1.8.21, 1.8.20, 1.8.19, 1.8.18, 1.8.17, 1.8.16, 1.8.15, 1.8.14, 1.8.13, 1.8.12, 1.8.11, 1.8.10, 1.8.9, 1.8.8, 1.8.7, 1.8.6, 1.8.5, 1.8.4, 1.8.2, 1.8.1, 1.8.0, 1.7.3, 1.7.2, 1.7.1, 1.7.0, 1.6.0, 1.5.3, 1.5.2
- הערה:
- הספרייה הזו תלויה ב-jQuery. צריך גם לטעון את jQuery לפני טעינה של המודול הזה. הגרסה 1.8.3 לא מתארחת בגלל משך החיים הקצר שלה, והכתובת החלופית
1.8.3
בעצם טוענת את הגרסה 1.8.4. - snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/listjs/2.3.1/list.min.js"></script>
- site:
- listjs.com
- גרסאות:
- 2.3.1
- snippet:
-
<script type="module">
import {
Draggable,
Point2DSpring,
Tossable,
combineStyleStreams,
getPointerEventStreamsFromElement,
} from "https://ajax.googleapis.com/ajax/libs/material-motion/0.1.0/material-motion.bundle.js";
</script> - site:
- https://github.com/material-motion/material-motion-js
- גרסאות:
- 0.1.0
- snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.0.0/model-viewer.min.js"></script>
- site:
- modelviewer.dev
- versions:
- 3.0.0, 2.1.1, 2.1.0, 2.0.2, 2.0.1, 2.0.0, 1.12.0, 1.11.1, 1.10.0, 1.9.0, 1.8.0, 1.7.2, 1.7.0, 1.6.0, 1.5.1, 1.3.1, 1.2.1, 1.1.0, 1.0.0
- snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/mootools/1.6.0/mootools.min.js"></script>
- site:
- mootools.net
- גרסאות:
- 1.6.0, 1.5.2, 1.5.1, 1.5.0, 1.4.5, 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0, 1.3.2, 1.3.1,1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
- הערה:
- בגרסאות 1.5.1 ומטה, שם הקובץ של הגרסה המוקטנת נקרא mootools-yui-compress.js במקום mintools.min.js.
- snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/myanmar-tools/1.2.1/zawgyi_detector.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/myanmar-tools/1.2.1/zawgyi_converter.min.js"></script>
- site:
- https://github.com/google/myanmar-tools/
- גרסאות מומלצות:
- 1.2.1
- כל הגרסאות המתארחות:
- 1.0.1
- 1.1.0
- 1.1.1
- 1.1.3
- 1.2.0
- 1.2.1
- snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.3.0/prototype.js"></script>
- site:
- prototypejs.org
- versions:
- 1.7.3.0, 1.7.2.0, 1.7.1.0, 1.7.0.0, 1.6.1.0, 1.6.0.3, 1.6.0.2
- 摘要:
-
<script src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>
- site:
- script.aculo.us
- 版本:
- 1.9.0、1.8.3、1.8.2、1.8.1
- 注意:
-
此库依赖于
Prototype
。在加载此模块之前,您必须先加载原型。 - קטע קוד:
-
<!-- for non-UI builds: -->
<script src="https://ajax.googleapis.com/ajax/libs/shaka-player/4.13.8/shaka-player.compiled.js"></script>
<!-- or, for UI builds: -->
<script src="https://ajax.googleapis.com/ajax/libs/shaka-player/4.13.8/shaka-player.ui.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/shaka-player/4.13.8/controls.css"> - site:
- https://github.com/google/shaka-player/
- גרסאות מתוחזקות:
- 4.13.8, 4.12.17, 4.9.36
- כל הגרסאות המארחות:
- 4.13.0 – 4.13.8, 4.12.0 – 4.12.17, 4.11.0 – 4.11.21, 4.10.0 – 4.10.26, 4.9.0 – 4.9.36, 4.8.0 – 4.8.20, 4.7.0 – 4.7.15, 4.6.0 – 4.6.18, 4.5.0, 4.4.0 – 4.4.3, 4.3.0 – 4.3.16, 4.2.0 – 4.2.14, 4.1.0 – 4.1.7, 4.0.0 – 4.0.5, 3.3.0 – 3.3.19, 3.2.0 – 3.2.21, 3.1.0 – 3.1.8, 3.0.0 – 3.0.15, 2.5.0-בטא – 2.5.23, 2.4.0 – 2.4.7, 2.3.0 – 2.3.10, 2.2.0 – 2.2.10, 2.1.0 – 2.1.9, 2.0.6 – 2.0.9, 1.6.5
- snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/spf/2.4.0/spf.js"></script>
- site:
- youtube.github.io/spfjs
- versions:
- 2.4.0, 2.3.2, 2.3.1, 2.3.0, 2.2.0, 2.1.2, 2.1.1, 2.1.0, 2.0.1, 2.0.0
- snippet:
-
<script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
- site:
- github.com/swfobject/swfobject
- versions:
- 2.2, 2.1
- 摘要:
-
<script src="https://ajax.googleapis.com/ajax/libs/threejs/r84/three.min.js"></script>
- site:
- threejs.org
- 版本:
- r84、r83、r82、r81、r80、r79、r78、r77、r76、r75、r74、r73、r72、r71、r70、r69、r68、r67 r49
- 代码段
-
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
- site:
- github.com/typekit/webfontloader
- 版本:
- 1.6.26、1.6.16、1.5.18、1.5.10、1.5.6、1.5.3、1.5.2、1.5.0
- מחפשים שגיאות הקלדה. חשוב לזכור ש-JavaScript היא שפה תלויי אותיות רישיות.
- משתמשים בכלי לניפוי באגים ב-JavaScript. ב-Chrome, משתמשים בכלי הפיתוח ל-Chrome. ב-Firefox, אפשר להשתמש ב-Firefox DevTools המובנה. ב-IE, אפשר להשתמש בכלים למפתחים של F12.
Ext Core
Hammer.JS
Indefinite Observable
jQuery
jQuery Mobile
jQuery UI
List.js
Material Motion
Model-Viewer
MooTools
Myanmar Tools
Prototype
script.aculo.us
Shaka Player
SPF
SWFObject
three.js
Web Font Loader
פתרון בעיות
רואים גרסה מיושנת? חשוב לוודא שאתם לא משתמשים בקישורים ל'גרסה אוטומטית', כמו /jqueryui/1/...
, אלא משתמשים בכתובות URL שמפניות לגרסאות מדויקות.
בגלל חששות לגבי שמירת נתונים במטמון וחוסר תאימות גם בין גרסאות משניות, הוצאנו משימוש את כינויי הגרסאות האוטומטיות והפסקנו לעדכן אותם לפני זמן מה. לכן, הם תמיד יפנו לגרסה ישנה (כדי לא לשבור אתרים קיימים שעדיין משתמשים בהם).
אם תיתקלו בבעיות: