ECMAScript proposal: JSON modules

Dr. Axel Rauschmayer looks at JSON modules, which is already live in Chrome 91 (but nothing else). It looks just like an ES Modules-style import, only you asset the type at the end.

import configData from './config-data.json' assert {type: 


The post ECMAScript proposal: JSON modules appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier

Dr. Axel Rauschmayer looks at JSON modules, which is already live in Chrome 91 (but nothing else). It looks just like an ES Modules-style import, only you asset the type at the end.

import configData from './config-data.json' assert {type: 'json'};

How nice is that? Once this makes its way across browsers, we’ve gone on a journey from “you’ll almost definitely want to use an Ajax library” because of the cross-browser complexity and weirdness of XMLHttpRequest to the much nicer (but you still gotta write some code) fetch API, to a one-liner (if what you need is JSON data).

Snagging some JSON data seems like it should be as easy as a one-liner to me, and now it is. I like how the URL can be dynamic now too.

Direct Link to ArticlePermalink


The post ECMAScript proposal: JSON modules appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier


Print Share Comment Cite Upload Translate Updates
APA

Chris Coyier | Sciencx (2021-07-21T21:08:08+00:00) ECMAScript proposal: JSON modules. Retrieved from https://www.scien.cx/2021/07/21/ecmascript-proposal-json-modules-2/

MLA
" » ECMAScript proposal: JSON modules." Chris Coyier | Sciencx - Wednesday July 21, 2021, https://www.scien.cx/2021/07/21/ecmascript-proposal-json-modules-2/
HARVARD
Chris Coyier | Sciencx Wednesday July 21, 2021 » ECMAScript proposal: JSON modules., viewed ,<https://www.scien.cx/2021/07/21/ecmascript-proposal-json-modules-2/>
VANCOUVER
Chris Coyier | Sciencx - » ECMAScript proposal: JSON modules. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/21/ecmascript-proposal-json-modules-2/
CHICAGO
" » ECMAScript proposal: JSON modules." Chris Coyier | Sciencx - Accessed . https://www.scien.cx/2021/07/21/ecmascript-proposal-json-modules-2/
IEEE
" » ECMAScript proposal: JSON modules." Chris Coyier | Sciencx [Online]. Available: https://www.scien.cx/2021/07/21/ecmascript-proposal-json-modules-2/. [Accessed: ]
rf:citation
» ECMAScript proposal: JSON modules | Chris Coyier | Sciencx | https://www.scien.cx/2021/07/21/ecmascript-proposal-json-modules-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.