Search code examples
angularopenlayers-5angular-openlayers

Why is adding Openlayers v5 to Angular (6) making the SPA download much larger?


Openlayers is a very nice package for working with maps.

My Spring Boot, Angular and Leaflet SPA has a vendor.js file of 4.2Mb. Replacing Leaflet by Openlayers 5 gives a vendor.js of 6.8Mb. Noticed differently: adding Openlayers to a bare Angular SPA increases the SPA by about 3Mb.

When I see many examples at https://openlayers.org only 2 files are included: ol.css and ol.js. When downloading the Openlayers v5 zip, then I can see that the files are only 4kb and 640Kb.

Why has the Single Page Application (SPA) download size increased by about 2.6Mb? Other *.js files increased also a bit. The application did not change.

I used the "npm install ol --save" to add Openlayers v5 to the Angular SPA.

Of course I can use the ng build --prod to optimize the build (sizes).


Solution

  • @Mike - thank you for pointing the way!

    When building for production with --prod any doubts vanished. The total size is about 1.5M! That's OK!