Menu

Build a Free Currency Converter for a Static Site: 25 Lines of JavaScript, No Backend
πŸ“°

Build a Free Currency Converter for a Static Site: 25 Lines of JavaScript, No Backend

DEV Community: javascriptΒ·chathuranga basnayakaΒ·5 days ago
#QDwTB62H
#devtojavascript#devto#dev#rates#base
Long article (689 words) β€” no AI summary yet.
Reading 0:00
15s threshold

Static sites can't hide an API key, which is why most currency converter tutorials end with "now set up a small server". You can skip that step: AllRatesToday's open endpoint needs no key and allows cross-origin requests, so the browser can call it directly.

Here's a complete converter for GitHub Pages, Netlify, Cloudflare Pages or a plain HTML file.

The HTML

<form id = "fx" > <input id = "amount" type = "number" value = "100" min = "0" step = "any" > <select id = "from" ></select> β†’ <select id = "to" ></select> <output id = "result" ></output> <small id = "asof" ></small> </form> <p><a href = "https://allratestoday.com" > Exchange rates by AllRatesToday </a></p>

Enter fullscreen mode

Exit fullscreen mode

The JavaScript

const $ = ( id ) => document . getElementById ( id ) ; let table = { base : null , rates : { } , date : "" } ;

async function load ( base ) { if ( table .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.