A current project involves creating a custom ICEC widget. Thankfully, Dmitri Prosper created a great starter utility for doing so.It's a Node.js application that uses webpack to build a finished JavaScript file that is your custom widget.

The custom widget I've been creating is quite complex and has involved a lot of to-ing and fro-ing in order to get it working. Finally I got there and tried to upload the finished widget to ICEC, as I've done before. But nothing appeared. Looking at the network tab, the POST failed with Error 500. Looking at the widget I was trying to upload, instead of just a few Kb, as previously, this one was 1.7Mb!

So I tried rebuilding it as a new widget, but still no joy. I tried removing a few functions that were now redundant following code refactoring. Still no joy. Finally, removing one line cut the size by nearly 1.2 Mb:

const xml2js = require("xml2js");

At one point in the development I had code that depended on this to try to parse the ATOM response from Connections, but I'd subsequently reverted to just using jQuery to parse the XML response. So it was no longer required. Removing that one line reduced the size from 1.7Mb to less than 500Kb. Add the line back in and build, it jumped back over 1.7Mb. Remove it and build, back down to less than 500Kb.

The lesson learned is to be aware of the size implications of code, but also to make the time to clean up and refactor regularly.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top