<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>RSS Feed for javascript - James Stone&apos;s Blog</title><description>Blog posts tagged with javascript</description><link>https://jamesst.one/</link><item><title>ESM HTTP imports</title><link>https://jamesst.one/posts/esm-http-imports/</link><guid isPermaLink="true">https://jamesst.one/posts/esm-http-imports/</guid><description>&lt;![CDATA[&lt;p&gt;When using all &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#browser_compatibility&quot;&gt;modern versions&lt;/a&gt; of JS you can use esm modules.&lt;/p&gt;
&lt;p&gt;What I did not realise is you can import modules at runtime over http(s).&lt;/p&gt;
&lt;p&gt;To help with this there are a range of CDNs that host the whole of NPM designed for ESM.&lt;/p&gt;
&lt;p&gt;Some examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://esm.sh/&quot;&gt;https://esm.sh/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://esm.run/&quot;&gt;https://esm.run/&lt;/a&gt; - from: &lt;a href=&quot;https://www.jsdelivr.com/&quot;&gt;https://www.jsdelivr.com/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { version, verify } &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;https://esm.run/jsonwebtoken-esm&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;console.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(version); &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// &quot;8.5.1&quot; at time of writing.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; token&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;  &quot;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwic2NvcGVzIjpbImEiLCJiIl0sImlhdCI6MTUxNjIzOTAyMn0.RYe2h0fD7XqWDxSepytntccG5-EfrdGmVmqwfhi36O0&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; decoded&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; verify&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(token, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;your-256-bit-secret&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;console.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(decoded);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;]]&gt;</description><pubDate>Thu, 22 Dec 2022 00:00:00 GMT</pubDate></item></channel></rss>