Search code examples
javascriptdjangofiwarefiware-wirecloud

Compress WireClouds JavaScript files


Every time I reload the WireCloud workspace it takes like forever to load all the JavaScript files. The network console of my browser indicates that there are about 300 requests to retrieve all needed JavaScript resources. Those resources my only take about 30ms to load each, but the huge amount of requests causes the dashboard to almost take a minute to fully load.

Even the initial WireCloud landing page uses about 250 requests and thus take like forever to load and does not really contain content.

So is there a way to compress those JavaScript files and / or to unify them? The files from the server even contain comments and linebreaks. As far as I know this should not be the case in JavaScript files that are used in production.


Solution

  • WireCloud uses django-compressor for unify JavaScript and CSS files and should be enabled if DEBUG is False in your settings.py file.

    I've tested in the FIWARE Lab's Mashup portal with a dashboard composed of 4 widgets and 4 operators, this lead to ~100 request (javascript files, initial ajax request, css files, ...). But take into account that almost all of those request should come from cache (they are no real requests):

    Request from cache

    Check your Apache configuration if you don't see this behaviour. Others requests should be returning a 304 error code, so they are real requests but of a ridiculous size if the response has not changed:

    enter image description here

    Anyway, we're working on reducing the required requests and we're open to any suggestion (would be great if you open a ticket with the suggestion of compressing WirecloudAPI files for widgets and operators).