Highlight.js: go.min.js:1 Uncaught ReferenceError: hljs is not defined

Created on 5 Nov 2016  路  2Comments  路  Source: highlightjs/highlight.js

Can't seem to get the lib working.

<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/go.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

<script>
    $(document).ready(function() {
        $('pre').each(function(i, block) {
            hljs.highlightBlock(block);
        });
    });
</script>

Most helpful comment

@sourrust I forgot I created this issue, I found it out myself already, Only thing I can say is that the docs are not very clear in that case.

All 2 comments

Right now you included the language but not the core library. You also only need to choose one initialization function, because initHighlightingOnLoad and the jQuery $(document).ready(function() { ... }) are essentially the same thing. So change your example to:

<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/languages/go.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

@sourrust I forgot I created this issue, I found it out myself already, Only thing I can say is that the docs are not very clear in that case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Suyash2810 picture Suyash2810  路  8Comments

kkeundotnet picture kkeundotnet  路  3Comments

gka picture gka  路  7Comments

starikovs picture starikovs  路  5Comments

starikovs picture starikovs  路  8Comments