Is there such a thing as a javascript deminifier (

2019-01-08 17:56发布

This question is exactly the opposite of Which Javascript minifier (cruncher) does the same things that the one Google uses for its JS APIs?

I want to learn how google does it's loading so I can build my own with non-popular JS toolkits.

9条回答
闹够了就滚
2楼-- · 2019-01-08 18:17

Try http://www.jsnice.org/

I just stumbled on it and it is great. It expands the code. It has statistical variable renaming. for example, if you have this code:

var g = f.originalEvent.targetTouches[0];

Then it it turns your code into:

var touches = event.originalEvent.targetTouches[0];

Pretty good guess, methinks.

It turned this:

d.slide.hasClass("selected") ? (e.onSlideOpen.call(d.prev.children("div")[0]), q ? (e.rtl && d.slide.position().left > i.w / 2 || d.slide.position().left < i.w / 2) && h.animateSlide.call(d) : t && d.index ? (h.animateGroup(d, !0), h.fitToContent(d.prev)) : d.slide.position().top < i.h / 2 && h.animateSlide.call(d)) : (setTimeout(function() { e.onSlideOpen.call(d.slide.children("div")[0]) }, e.slideSpeed), h.animateGroup(d), t && h.fitToContent(d.slide)), e.autoPlay && (f.stop(), f.play(l.index(j.filter(".selected"))))

Into this:

if (e.slide.hasClass("selected")) {
    settings.onSlideOpen.call(e.prev.children("div")[0]);
    if (val) {
      if (settings.rtl && e.slide.position().left > box.w / 2 || e.slide.position().left < box.w / 2) {
        self.animateSlide.call(e);
      }
    } else {
      if (isMac && e.index) {
        self.animateGroup(e, true);
        self.fitToContent(e.prev);
      } else {
        if (e.slide.position().top < box.h / 2) {
          self.animateSlide.call(e);
        }
      }
    }
  } else {
    setTimeout(function() {
      settings.onSlideOpen.call(e.slide.children("div")[0]);
    }, settings.slideSpeed);
    self.animateGroup(e);
    if (isMac) {
      self.fitToContent(e.slide);
    }
  }
  if (settings.autoPlay) {
    node.stop();
    node.play(tabs.index(options.filter(".selected")));
  }

A library I'm working on has a couple of bugs, and after spending hours trying to decipher the code, finding this is going to save me a bunch of time.

Seriously, this tool wipes the floor with JS Beautifier.

查看更多
smile是对你的礼貌
3楼-- · 2019-01-08 18:25

You can use the \b (word boundary) feature in regular expressions to find single-letter variable names in a file.

for i in "abcdefghij..z"; do
    sed -i "s/\b$i\b/$(random /usr/share/dict/words)/g" somefile.js
done

You can also use this in vim with something like :%s/\<a\>/truesaiyanpower/g.

查看更多
男人必须洒脱
4楼-- · 2019-01-08 18:34
登录 后发表回答