flibbles / tw5-uglify

Compress TiddlyWiki5 javascript and plugins
Other
18 stars 2 forks source link

Uglify does not work with Tiddlywiki 5.2 #2

Closed kookma closed 2 years ago

kookma commented 3 years ago

Hi @flibbles

As discussed here https://groups.google.com/g/tiddlywiki/c/kF-OGmkyFfo/m/b272I2rtAwAJ Uglify does not work or work in reverse for Tiddlywiki 5.2

I would appreciate to have a look!

flibbles commented 3 years ago

Yeah... I looked into it a bit. In V5.2 of Tiddlywiki, they completely changed how the tiddlers are written to the file. It doesn't use the ViewWidget anymore, and I'm honestly not sure how Uglify is supposed to intercept the work anymore. There isn't any place for me to get in anymore.

I think I vaguely found one place, but it adds overhead pretty much to every attempt to render any tiddler at any point.

So then I kinda petered out...

flibbles commented 3 years ago

I'm honestly not sure how to fix it. If I had known they were going to revamp the tiddler writing to what it is now, I wouldn't have created Uglify. It wouldn't have passed my proof of concept.

flibbles commented 3 years ago

There, I pushed the hack I tried. It's shitty, but you can use it to compress plugins. Just make sure you scrap Uglify after your compression is done, because this slows up all of Tiddlywiki if you keep Uglify in.

Frankly, I think I'm going to drop Uglify support from here on out. It doesn't gel with Tiddlywiki anymore, and there hasn't really been enough demand for Uglify to warrant the work. Hope what I've pushed is good enough.

kookma commented 3 years ago

@flibbles thank you for your efforts! It is pity we cannot have Uglify for 5.2

I will keep using TW 5.1.23 as Uglify works for it and makes it half size when compressed!

flibbles commented 3 years ago

As long as you're only using Uglify to compress once, and then you remove Uglify, it can work for V5.2.*, it just adds a lot of overhead.

The problem is that ViewWidget isn't used anymore to render tiddlers for file. Instead, all the new JSON stuff just calls JSON.toString for the whole tiddler library, which I'm sure is efficient, but it doesn't give me anywhere to jump in. So I'm having to jump in whenever a tiddler's text is rendered AT ALL and apply compression then, which means performing checks every single time Tiddlywiki rerenders a tiddler for any reason.

kookma commented 3 years ago

Thank you! I understand! I think for may use cases TW 5.1.23 is sufficient and I stick to it! Uglify gives me 1.2MB for empty.html!

flibbles commented 2 years ago

As far as I can tell, Uglify is working. Where are you trying to use it? Because apart from a cutting-edge version off of the code-source, it won't work yet. For instance, it won't work on the TW5.com website right now.

kookma commented 2 years ago

As far as I can tell, Uglify is working. Where are you trying to use it? Because apart from a cutting-edge version off of the code-source, it won't work yet. For instance, it won't work on the TW5.com website right now.

I tested it like 5.1.23 e.g. download a newly empty.html install many plugins (codemirror, highlight.js, katex, ....) install uglify, save, delete uglify, save again, reload!

it won't work on the TW5.com website right now.

I tested on a newly downloaded empty.html from tiddlywiki.com/prerelease.

flibbles commented 2 years ago

Still works for me. Is it possible you're not using Uglify 1.0.3? I had to push a new release to work with the new jsontiddler.

kookma commented 2 years ago

Still works for me. Is it possible you're not using Uglify 1.0.3?

Ah my bad, I am using Uglify 1.0.2!

flibbles commented 2 years ago

No worries. If I ever get around to it. I'd like to change the Uglify demo website to have a "drag your project here to minify and return." Sort of like how the TiddlyWiki online updater works. That would prevent issues like this.

Just got to find the time though.