Search code examples
javascriptcssminify

Why are online minifiers changing my code?


Why are online minifiers changing my code?

I have on my original code ...

if (typeof Object.create !== "function") {
    Object.create = function (obj) {
    function F() {}
    F.prototype = obj;
    return new F();
};
}
(function ($, window, document) {

var Carousel = {
    init : function (options, el) {
        var ba ........

and the minifier returns...

"function"!=typeof Object.create&&(Object.create=function(t){function e(){}return e.prototype=t,new e}),function(t,e,o){var i={init:function(e,o){var i=this;i.$elem=t(o),i.options=t.extend({},t.fn.owlCarousel.options,i.$elem.data(),e),i.userOptions=e,i.loadContent()},loadContent:function(){var e,o=this;"function"==t....

Can I get a recommendation for an online minifier that respects my code and only eliminates comments and unnecessary spaces for my CSS and JAVASCRIPTS?


Solution

  • It doesn't really change your code! It uglifies your code, mangles names and properties and function names. That's really a minifier does. If you don't want any of this options you can use https://www.uglifyjs.net/ that allows you to choose your options.