question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why is ReactDOM a separate file on the CDN?

See original GitHub issue

When loading React from the CDN, we now need to include two separate files:

<script src="https://fb.me/react-0.14.2.js"></script>
<script src="https://fb.me/react-dom-0.14.2.js"></script>

Why? Given the primary use of React via CDN is for browsers, shouldn’t we bundle them together? When would you ever load react-0.14.2.js via the CDN without loading react-dom-0.14.2.js?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
Daniel15commented, Nov 7, 2015

There are a non-trivial number of people doing global replacement in their builds with webpack. This replaces var whatever = require(‘react’) with var whatever = React, so it’s actually a good idea to keep the objects aligned.

Sure, but providing two globals (React and ReactDOM) doesn’t mean they need to be in two totally separate JavaScript files 😃

Since loading both is the most common case right now, wouldn’t it be beneficial to provide one .js file with both (say react-full.js or something like that)?

1reaction
prasannavlcommented, Feb 27, 2016

To take that even further: this could actually make React a lot smaller since with an optional flag, since its opens up the possibility of only sending in custom builds which open up browser specific requirements, removing all compatibility layers. So, based on the User-Agent, the react dependency served directly from the CDN can be only specific to that particular browser. Less code, smaller network packages, lesser latency, more smiling faces.

React has to starting modularizing even more for that, allowing custom builds removing compatibility layers, but this could be a very interesting area to explore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why React and React-DOM Libraries are Kept in Two ...
We might have noticed that, even though React and React-DOM are used together always, we include them from two separate packages.
Read more >
CDN Links - React
Both React and ReactDOM are available over a CDN. To load a specific version of react and react-dom , replace 18 with the...
Read more >
ReactDOM render not working using CDN links - Stack Overflow
I do see a warning from React that ReactDOM.render is deprecated, but not sure if that's related. – Alan Friedman. Jul 7 at...
Read more >
How React.js CDN Makes Your Life Incredibly Easier - Copycat
In this blog post, we will discuss all about setting up reactjs cdn and how it is beneficial to your react project.
Read more >
What is CDN React DOM and Its Benefits
Other Benefits of CDN React DOM · IPV4/IPV6 Dual-Stack Network · Intuitive User Interface · Real-time Data and Information · Developer-Friendly · Instant...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found