Hello,
i like the BANano feature MinifyOnline very much. But -- to be honest -- I don't have a good feeling about sending my code to an online service.
That's why I wrote a small PostProcessor that, when compiled as a B4J lib, can compress JavaScript "offline" after BANano has done its job. For this I use Terser (https://github.com/terser-js/terser), which can be installed as NodeJs npm module. (I don't like NodeJS, but as far as I know there is no standalone tool available that produces better results.)
My current project will be reduced from about 182 kB to about 93 kB within 1.5 seconds with Terser's default settings. I think, that's not bad.
At the moment the PostProcessor can only compress the JS, but maybe I (or you?) will have ideas for futher features later.
Prerequisites:
How to use:
Feel free to post questions, suggestions or bug reports.
Have fun & Greetings ... Peter
i like the BANano feature MinifyOnline very much. But -- to be honest -- I don't have a good feeling about sending my code to an online service.
That's why I wrote a small PostProcessor that, when compiled as a B4J lib, can compress JavaScript "offline" after BANano has done its job. For this I use Terser (https://github.com/terser-js/terser), which can be installed as NodeJs npm module. (I don't like NodeJS, but as far as I know there is no standalone tool available that produces better results.)
My current project will be reduced from about 182 kB to about 93 kB within 1.5 seconds with Terser's default settings. I think, that's not bad.
At the moment the PostProcessor can only compress the JS, but maybe I (or you?) will have ideas for futher features later.
Prerequisites:
- Download and install NodeJS (https://nodejs.org/en/)
- Execute the following command in the CMD: npm install terser -g
(see also: https://www.npmjs.com/package/terser)
How to use:
- Download and unpack the attached ZIP
- Load the BANanoPostProcessorProject.b4j and compile it to a Lib. B4J will place it automatically to the additional libraries folder.
- Load your BANano-Project and insert the following code:
B4X:
Sub Process_Globals
Private BANano As BANano
Private BP As BANanoPostProcessor
' ...
End Sub
Sub AppStart(Form1 As Form, Args() As String)
Dim appShortName As String = "[YourProjectName]"
BANano.Initialize([YourEventName], appShortName, DateTime.Now)
' ...
' BANano-Stuff
' ...
Dim BuildFolder As String = "C:\inetpub\wwwroot\BANano\" ' <- adjust to your needs!
BANano.Build(BuildFolder)
' ####
#If Release ' It is recommended to use the Compress command only in release mode.
BP.Initialize
BP.ScriptFilename = BuildFolder & appShortName & "\" & BANano.SCRIPTS_FOLDER & "\" & BANano.JAVASCRIPT_NAME
BP.Compress
#End If
' ####
ExitApplication
End Sub
Feel free to post questions, suggestions or bug reports.
Have fun & Greetings ... Peter
Attachments
Last edited: