Search code examples
javascriptminifybundling-and-minificationdygraphs

difference of behaviour between dygraphs.js and dygraphs.min.js


I am using the dygraphs library in javascript. I needed to debug something so I switched from the minified version to the non-minified one but I then got different behaviours.

Changing nothing in my code except

<script src="/node_modules/dygraphs/dist/dygraph.min.js"></script>

into

<script src="/node_modules/dygraphs/dist/dygraph.js"></script>

In my case, dygraphs.min.js accepts extra fields in the option object used in

let g = new Dygraph(
    document.getElementById(divName),
    data,
    options
);

whereas dygraphs.js fails with the message

invalid option the_name_of_my_extra_field

Is that expected ?


Solution

  • This is working as intended. The debug build warns on invalid options because these are likely to be mistakes (misspelled option names, etc.):

    > new Dygraph(div, data, { made_up_option: false });
    Uncaught invalid option made_up_option
    

    These checks are stripped out of the production build to reduce code size and improve performance.