React script unpkg
#React script unpkg how to#
#React script unpkg how to#
At the time of this writing, that’s what the React docs show you how to do it for basic examples, i.e.: ReactDOM. Granted, you can author in JSX and ship it directly to the browser. (Once we get stuff like import maps you wouldn’t even have to do this.) I import the libraries in one place and export them for use in other files. For example, having a deps.js file makes it so I don’t have to write out those long CDN URLs all the time. Then my index.js file: import ` īut as I mentioned, I like splitting the JavaScript out into individual modules because it helps me expand and grow the functionality over time. If it becomes viable longer term, I then consider factoring in a build process, removing my dependence on React, etc.įirst, I have my root HTML file ( index.html): Title of Your Page This is a great place to start with an idea. The code I write is the code that ships to the browser. It allows me to leverage React and write JSX-like syntax without any dependence on a build tool. Ok, so, with that context in mind, I have this little boilerplate I’ve pieced together from a couple different sources (big thanks to the preact docs). computer-“can I get this working?”-and I find that I’ll move heaven and earth just to see something work only to realize that what I wanted to do was building something usable in a browser, not optimize and streamline my “DX”. It’s like I immediately forget that I was trying to build something useful and instead it becomes a fight of nerd vs. The moment configurations, build processes, and what not get involved, those become the focus of my attention. Using a framework like React can make doing that incredibly easy-as long as there is no build tooling involved. I find myself quite often needing to prototype something really quick, sometimes even build an “MVP” of something I can put out into the world for feedback. First off: this is mostly a reference for myself.
















