JavaScript Upgrade Strategy #6: Code Removal

One of my absolute joys when upgrading a Dynamics CRM organization from 4.0 to 2011 is the chance you get to actually remove JavaScript from your system.

Remember: Code that you do not have, is code you do not have to maintain.

Part of the consolidation process is to remove as much JavaScript as you can, while keeping the existing functionality.

This is a multi-step process that involves several phases.  Here is how I like to approach it:

 

Import of external JavaScript files

At some customers we created centralized JavaScript libraries that were disk-based and not physically stored within the database. This allowed us a single maintenance point since we could reference these files from any entity.  This process, while common, was very unsupported.

With Dynamics CRM 2011 the web resource model allows us to create the exact same shared-code design but one that is supportable.

All we have to do is create new web resources containing the previously disk-based JavaScript.  We can also remove the code that was required to load the disk-based JavaScript since it is totally unnecessary.

 

Code replaced by internal Dynamics CRM 2011 methods

Some of the features we created using JavaScript in Dynamics CRM 4.0 have been replace by native Dynamics CRM 2011 (and later 2013) features.  Anything that we coded for will be better served, in most cases, by using the native methods so that code can be deleted.

Again, this is where source control is a great help to keep you from loosing your place or accidentally loosing functionality by removing too much JavaScript.

 

Empty methods added by the upgrade process

When you physically upgrade your 4.0 organization you will sometimes find empty JavaScript functions associated with fields or iFrames.  These can be safely deleted and their event-handler references removed.

Leave a Reply