Difference between revisions of "pas2js minifier"
From Free Pascal wiki
Jump to navigationJump to search (Started tipps and tricks for reducing js code size) |
(No difference)
|
Revision as of 17:33, 19 November 2018
Overview
This page explains ways to reduce and/or compress the pas2js generated JavaScript.
Omit unneeded code
- Use pas2js option -Jc to generate one JavaScript program. This allows the compiler to use Whole Program Optimization (wpo) to determine all unused identifiers.
- Use -O1 to omit unused identifiers. If a record/class is used, every unused member/method is omitted.
- By default published properties/methods are kept and will generate type information (RTTI). If you don't need that you can ...
- use {$modeswitch omitrtti} (since pas2js 1.1), which treats class section 'published' as 'public' and typeinfo() does not work on symbols declared with this switch.
- use -OoRemoveNotUsedPublished to omit all published properties not referenced at compile time.
Third party minifier
There are several free minifiers for JavaScript. A minifier removes unneeded characters and replaces some code without changing its functionality.
As an example here is how to use uglifyjs with pas2js: