Home > Enterprise >  Why javascript uncaught reference error for beautify library
Why javascript uncaught reference error for beautify library

Time:09-04

I'm testing https://www.npmjs.com/package/js-beautify

with

https://jsfiddle.net/pLwcv97x/

  window.addEventListener('load', (e) => {
    console.log("test");
    beautify("<html></html>", { indent_size: 2, space_in_empty_paren: true })
  });

I added library in html

  <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.6/beautify.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.6/beautify-css.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.6/beautify-html.js"></script>

CodePudding user response:

you should use js_beautify instead of beautify:

js_beautify("<html></html>", { indent_size: 2, space_in_empty_paren: true })

CodePudding user response:

There could be a number of reasons why you are getting an Uncaught Reference Error when using the Beautify library. It is possible that the library is not loaded correctly, or that there is a conflict with another library. It is also possible that the code you are using is not compatible with the Beautify library.

  • Related