Gzipping static assets

28 views
Skip to first unread message

Luc Didry

unread,
Apr 23, 2018, 8:39:40 AM4/23/18
to Mojolicious
Hello,

I just released a new Mojolicious plugin,
Mojolicious::Plugin::GzipStatic
(https://metacpan.org/pod/Mojolicious::Plugin::GzipStatic)

It monkey patch Mojolicious::Static to compress the static assets
before service them if the browser supports it and if the asked asset
is text (js, css, xml, etc) (since compressing png, jpg, mp4, etc is
useless).

Advices and patches[1] welcome 🙂

(Maybe it could be a core feature, don't you think?)

[1] https://framagit.org/luc/mojolicious-plugin-gzipstatic/issues
--
Luc
https://fiat-tux.fr/
https://luc.frama.io/
Internet n'est pas compliqué, Internet est ce que vous en faites.

sri

unread,
Apr 23, 2018, 8:47:39 AM4/23/18
to Mojolicious
Advices and patches[1] welcome 🙂

Please don't monkey patch like that, it is very bad style. I don't see anything there
that couldn't also be done with a clean role and after/around. Or perhaps even an
after_static_dispatch hook.

--
sebastian

sri

unread,
Apr 23, 2018, 8:49:00 AM4/23/18
to Mojolicious
(Maybe it could be a core feature, don't you think?)

No, i don't think so, loading very large assets into memory to compress
them would be fatal.

--
sebastian

Luc Didry

unread,
Apr 23, 2018, 9:45:40 AM4/23/18
to mojol...@googlegroups.com
You mean after_static hook, don't you? I can't find a trace of
after_static_dispatch in Mojolicious code.

I just patched my plugin according to your advice, thank you đź‘Ť

Luc Didry

unread,
Apr 23, 2018, 9:47:10 AM4/23/18
to mojol...@googlegroups.com
lundi 23 avril 2018, 05:49:00 CEST sri wrote:
> No, i don't think so, loading very large assets into memory to
> compress them would be fatal.

Too bad, it would have been cool.

Thank you.
Reply all
Reply to author
Forward
0 new messages