I was following the steps and wrote a demo HTML. Here are the steps in the README of https://github.com/commonmark/commonmark.js#commonmarkjs :
For client-side use, you can do
make dist
to produce a standalone JavaScript filejs/dist/commonmark.js
, suitable for linking into a web page, or fetch the latest from https://raw.githubusercontent.com/jgm/commonmark.js/master/dist/commonmark.js, orbower install commonmark
.
Here is my demo HTML.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://raw.githubusercontent.com/jgm/commonmark.js/master/dist/commonmark.js"></script>
<script>
window.onload = function() {
console.log(commonmark)
}
</script>
<body></body>
</html>
Here is a JSFiddle URL for my demo: https://jsfiddle.net/y3xohp7x/
I saved this HTML locally in a file named foo.html
and opened this local file with Firefox 55.0.1.
But if I load it with Firefox 55.0.1, I get the following errors in the console.
Loading failed for the <script> with source “https://raw.githubusercontent.com/jgm/commonmark.js/master/dist/commonmark.js”. foo.html:5
ReferenceError: commonmark is not defined foo.html:9:5
Questions:
- Why does this error occur?
- How can I resolve this error without having to copy
commonmark.js
to the local filesystem? - Is it a bug in the commonmark.js README documentation that I quoted above or is it an error in my understanding of the documentation?