Jump to content

babylon.max.js inside release bundle


Recommended Posts

Hello guys,

In our angular 4 application with webpack we are using the NPM package of babylonjs.

After I ran the following lines of code ...

npm run build-release-bundle-analyze


npm run bundle-report

... I realized that Babylon takes a lot of space of the total application size:



How does it come that babylon.max.js is used inside a release bundle instead of the minified version?


Can you in future seperate the "core" package of babylon even more so the "heavy" stuff, which some people may not need (we are not developing a game with bjs), can be left out?


Regards and Thanks


Link to comment
Share on other sites

Hello Deltakosh, 

thanks for your answer!

We are using it the proper way as for example:

import { Engine, Scene, ArcRotateCamera, AbstractMesh, Color4 } from 'babylonjs';


Webpack should automatically take the minified version by itself.

It works for any other library except babylonjs.

We are using stable Version 3.1.1

Link to comment
Share on other sites


The default file delivered is actually the max file which is unminified. the minified file is included in the package.

The main file has always been the max file and this is why I haven't changed it. I can of course consider delivering the minified file as the main file, so when you import from "babylonjs" you automatically get the minified one. I will discuss it internally with the team and update here :) 

Starting 3.2.0-alpha0 (currently in alpha4) the directory structure of the npm package was changed, so if you use javascript (won't work in typescript due to the declaration file) you can do this:

import * as BABYLON from 'babylonjs/babylon';

Or, of course, only load the files you need. this will load the minified file instead of the max file. A word of caution - as different modules reference "babylonjs" and not "babylonjs/babylon" you might include both if you use GUI (for example).

Just as a general question (and really - only our of curiosity) - why don't you add minification to the build process? a simple webpack plugin and you have everything minified as you wish.

Link to comment
Share on other sites

@inxs, regarding your first question - yes, the plan is to actually deliver modules. Our main problem are internal dependencies in main classes like the scene and engine, that shouldn't change. I am working on a solution for this that will be released with the final 3.2 (and hopefully sooner). So you could load modules and not the entire framework every time.


Link to comment
Share on other sites

Hello @RaananW,

thanks for your detailed answer.

We using Angulgar CLI for our builds, so we dont have influence on which file it is using :unsure:


But I think we will wait ultil 3.2.0 is release and then we will use the benefits of the modules!


Im looking forward to it! 3.1.1 made a giant leap in performance from my perspective. Babylon is getting better every day!

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...