codesandbox / codesandbox/codesandbox-client
Vanilla JS evaluate breaks browser execution order when script with async/defer is used
@DeMoorJasper is already working on this.
Since May 25, 2021.
- Dominant language
- JavaScript
- Stars
- 13.6k
- Forks
- 2.4k
- Avg merge
- 6d 19h
- Merged PRs (30d)
- 2
Description
Description of the problem
l am trying to use Google Maps in codesandbox with the Vanilla JS template. This is unique in that the historic way to load the library was through a script tag similar to the following:
<script
async
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
></script>
The issue is that the app.js (loaded in HTML head without defer or async attributes on the script tag) is not actually available and now asynchronous. This leads to a predictable error since initMap is not defined when it should be.
This works locally with the same files.
How has this issue affected you? What are you trying to accomplish?
This blocks me from using codesandbox for the hundreds of samples with this pattern. Not all users are interested in dynamically loading the Google Maps API via JavaScript.
To Reproduce
See attached sandbox.
Link to sandbox: link
Your Environment
| Software | Name/Version |
|---|---|
| Сodesandbox | |
| Browser | |
| Operating System |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.