Skip to content

Commit bd53169

Browse files
Added a basic usage section for CDNs
1 parent 31fb8bc commit bd53169

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,27 @@ <h1>Basic usage</h1>
152152
<p>If you want to prevent any elements from being automatically highlighted, you can use the attribute <code>data-manual</code> on the <code>&lt;script></code> element you used for prism and use the <a href="extending.html#api">API</a>.
153153
Example:</p>
154154
<pre><code>&lt;script src="prism.js" data-manual>&lt;/script></code></pre>
155+
<h2>Usage with CDNs</h2>
156+
157+
<p>In combination with CDNs, we recommend using the <a href="plugins/autoloader">Autoloader plugin</a> which automatically loads languages when necessary.</p>
158+
159+
<p>The setup of the Autoloader, will look like the following. You can also your own themes of course.</p>
160+
161+
<pre><code>&lt;!DOCTYPE html>
162+
&lt;html>
163+
&lt;head>
164+
...</code>
165+
<code class="highlight">&lt;link href="https://myCDN.com/prism@v1.x/themes/prism.css" rel="stylesheet" /></code>
166+
<code>&lt;/head>
167+
&lt;body>
168+
...</code>
169+
<code class="highlight" style="display: inline-block; outline-offset: .2em; margin-bottom: .2em;"> &lt;script src="https://myCDN.com/prism@v1.x/components/prism-core.min.js"&gt;&lt;/script&gt;
170+
&lt;script src="https://myCDN.com/prism@v1.x/plugins/autoloader/prism-autoloader.min.js"&gt;&lt;/script&gt;
171+
&lt;script&gt;Prism.plugins.autoloader.languages_path = 'https://myCDN.com/prism@v1.x/components/'&lt;/script&gt;</code>
172+
<code>&lt;/body>
173+
&lt;/html></code></pre>
174+
175+
<p>CDNs which provide PrismJS are e.g. <a href="https://cdnjs.com/libraries/prism">cdnjs</a> and <a href="https://www.jsdelivr.com/package/npm/prismjs">jsDelivr</a>.</p>
155176

156177
<h2>Usage with Webpack, Browserify, & Other Bundlers</h2>
157178

0 commit comments

Comments
 (0)