From 922ec555408a4631ef69c0cd1206d995edfee6f2 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sun, 30 Jun 2019 03:54:26 +0200 Subject: [PATCH] Website: Added basic usage for CDNs (#1924) Per [suggestion](https://github.com/PrismJS/prism/issues/1922#issuecomment-497681398) by @foxycode, I added an example for the usage of Prism with CDNs. --- index.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/index.html b/index.html index ae717859ee..fef21c9757 100644 --- a/index.html +++ b/index.html @@ -152,6 +152,27 @@

Basic usage

If you want to prevent any elements from being automatically highlighted, you can use the attribute data-manual on the <script> element you used for prism and use the API. Example:

<script src="prism.js" data-manual></script>
+

Usage with CDNs

+ +

In combination with CDNs, we recommend using the Autoloader plugin which automatically loads languages when necessary.

+ +

The setup of the Autoloader, will look like the following. You can also your own themes of course.

+ +
<!DOCTYPE html>
+<html>
+<head>
+	...
+	<link href="https://myCDN.com/prism@v1.x/themes/prism.css" rel="stylesheet" />
+</head>
+<body>
+	...
+	<script src="https://myCDN.com/prism@v1.x/components/prism-core.min.js"></script>
+	<script src="https://myCDN.com/prism@v1.x/plugins/autoloader/prism-autoloader.min.js"></script>
+	<script>Prism.plugins.autoloader.languages_path = 'https://myCDN.com/prism@v1.x/components/'</script>
+</body>
+</html>
+ +

CDNs which provide PrismJS are e.g. cdnjs and jsDelivr.

Usage with Webpack, Browserify, & Other Bundlers