Import your JSON and CSS as ES Modules

preview_player
Показать описание
Did you know that it is now possible to import JSON files and CSS files as Modules, instead of using Fetch?
As of Chrome 91 and Chrome 93 respectively we can do this with static or dynamic imports.

Fingers crossed that Safari catches up soon.

Рекомендации по теме
Комментарии
Автор

I like your channel ....you constantly push updated the course all the time ....by the way i like your react

sohailshah
Автор

Whenever I watch a video lesson here, I am convinced - JavaScript is a super language

Just watching the lesson calmly provides very clear explanations to so many topics

Thanks Steve 👍

barungh
Автор

I found I could not load css modules where media=print. I am just learning and experimenting and thought you might confirm whether this is a limitation.

RalphGoddard-ttxq
Автор

Is there any support for type: 'html'? Or at least, do you think that's coming in the future? I was going to use HTML5 Imports to replace my iframe tags, but it seems like Google has declared that deprecated since no other browser adopted it. And everywhere I look, people are saying that ES6 Modules are replacing HTML imports, but I haven't seen any guides on how to replace iframe tags with ES6 Modules.

leviuzodike
Автор

Hello Steve, thank you for all the videos that you are creating. I wanted to try importing a data.json using import and got this error in console: "Uncaught SyntaxError: Cannot use import statement outside a module". I am executing in Chrome 98. Any idea about what is causing this issue? Thanks.

cgarafulic
Автор

Why do this instead of
fetch("/data.json").then(r => r.json())
?

nitsanbh
Автор

Hi, thank you for you help it works perfectly with CSS file.
Do you have any clue for .LESS file ? In my case all inheritance class are ignored :/

geraldlgq
Автор

Is this server side rendering of css and json, beacause css isnt directed included in html file it is in js file and js rendering i to html page.

Please explain it to me.

BalkanLeaksArchive
Автор

Hello, very nice video.
I did it and in chrome works perfectly, but in safari, i get an error:: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
Could you help me with this?
Thank you very much.

angeloszaimis