Skip to content

Commit

Permalink
Website: Added basic usage for CDNs (#1924)
Browse files Browse the repository at this point in the history
Per [suggestion](#1922 (comment)) by @foxycode, I added an example for the usage of Prism with CDNs.
  • Loading branch information
RunDevelopment authored and mAAdhaTTah committed Jun 30, 2019
1 parent d673d70 commit 922ec55
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,27 @@ <h1>Basic usage</h1>
<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>.
Example:</p>
<pre><code>&lt;script src="prism.js" data-manual>&lt;/script></code></pre>
<h2>Usage with CDNs</h2>

<p>In combination with CDNs, we recommend using the <a href="plugins/autoloader">Autoloader plugin</a> which automatically loads languages when necessary.</p>

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

<pre><code>&lt;!DOCTYPE html>
&lt;html>
&lt;head>
...</code>
<code class="highlight">&lt;link href="https://myCDN.com/prism@v1.x/themes/prism.css" rel="stylesheet" /></code>
<code>&lt;/head>
&lt;body>
...</code>
<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;
&lt;script src="https://myCDN.com/prism@v1.x/plugins/autoloader/prism-autoloader.min.js"&gt;&lt;/script&gt;
&lt;script&gt;Prism.plugins.autoloader.languages_path = 'https://myCDN.com/prism@v1.x/components/'&lt;/script&gt;</code>
<code>&lt;/body>
&lt;/html></code></pre>

<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>

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

Expand Down

0 comments on commit 922ec55

Please sign in to comment.