How to unminify the js files?

Adarsha Beleyur picture Adarsha Beleyur · May 3, 2018 · Viewed 29.7k times · Source

How can I unminify js file which is minify from webpack tool.

Before minify,

function autoslideSlider() {
  $('.next-slide').trigger('click');
}
$(window).on('load', function(){
  $('.preloader').fadeOut('fast');
     $('#after_load').addClass('show');
     setInterval(autoslideSlider, 8000);
});
$('a').on('click', function () {
    if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
        var $target = $(this.hash);
        $target = $target.length && $target;
        // $('[name=' + this.hash.slice(1) + ']');
        if ($target.length) {
            var targetOffset = $target.offset().top - 20;
            $('html,body').animate({
                scrollTop: targetOffset
            }, 1500);
            return false;
        }
    }
});

After minify,

!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){function n(){$(".next-slide").trigger("click")}$(window).on("load",function(){$(".preloader").fadeOut("fast"),$("#after_load").addClass("show"),setInterval(n,8e3)}),$("a").on("click",function(){if(location.pathname.replace(/^\//,"")===this.pathname.replace(/^\//,"")&&location.hostname===this.hostname){var e=$(this.hash);if((e=e.length&&e).length){var t=e.offset().top-20;return $("html,body").animate({scrollTop:t},1500),!1}}})}]);

How can I unminify the above js file?

I want minified js file back into original format.

Can anyone tell me the tools or way to unminify the js file?

Answer

Cristian Traìna picture Cristian Traìna · May 3, 2018

You can't unminify a minified file. Minification is a desctructive operation and involves loss of information.

For example, if you have a function with a descriptive name, after minifcation that name will be substitute with a meaningless one. There's no way to go back from this operation.

You can use a beautifier to make it more readable, but you will have a weighty job of reverse engineering in order to understand what the code means.