Dr. Axel Rauschmayer appears at JSON modules, which is already stay in Chrome 91 (however nothing else). It appears identical to an ES Modules-style import, solely you asset the sort on the finish.
import configData from ‘./config-data.json’ assert {kind: ‘json’};
How good is that? As soon as this makes its approach throughout browsers, we’ve gone on a journey from “you’ll nearly undoubtedly wish to use an Ajax library” due to the cross-browser complexity and weirdness of XMLHttpRequest to the a lot nicer (however you continue to gotta write some code) fetch API, to a one-liner (if what you want is JSON information).
Snagging some JSON information looks as if it needs to be as simple as a one-liner to me, and now it’s. I like how the URL might be dynamic now too.
Direct Hyperlink to Article — Permalink
The publish ECMAScript proposal: JSON modules appeared first on CSS-Tips. You possibly can assist CSS-Tips by being an MVP Supporter.
Subscribe to MarketingSolution.
Receive web development discounts & web design tutorials.
Now! Lets GROW Together!