Alfresco Share min.js File and Dependency Cache

Here I am going to discuss one of the very important points for alfresco developers which help them in alfresco share development. Alfresco share is depends on spring-surf framework which uses javascript extensively. Now sometimes you need to change those javascript files to customize alfresco share functionality.

When you look at the source of any of alfresco share page you will see alfresco share page has included all related javascript files but there is some random number assigned at the end of each of those file name and you just keep wondering why is that? Is it pointing to that original javascript files which are lying under installation?

Alfresco Share Page Source

Alfresco Share Page Source

Here is the answer

The file you’re seeing should be the same file with an MD5 checksum appended to the end – this allows us to set an infinite expiry date on the resource and ensures that the browser cache will never contain stale data because if the file contents changes the MD5 checksum will change and the browser will be forced to request the new version of the file. Surf caches the resources more aggressively than ever before so you may need to click on the “Clear Dependency Cache” button on the WebScripts home page to avoid restarting the server.

Other possibility is that you will see file names as *-min.js means all included script file names with pattern having “min.js” appended in end. You will again wonder, what is this?

Answer:

These are minified, or compressed, to reduce the size of a given page and increase client-side performance.

If the file you’re seeing is minified then it suggests that you’re running in production mode and the Surf will be finding the pre-minified JavaScript resource.

Generally in development environment you want to use non-minified version of file to test your changes rapidly without server restart. To achieve that you need to add following entry in your share-config-custom.xml

<config replace="true">

       <flags>

           <client-debug>true</client-debug>

           <client-debug-autologging>false</client-debug-autologging>

       </flags>

   </config>

Share page in Debug Mode

Share page in Debug Mode

Share page in Debug Mode

As you can after enabling debug mode you have change in the suffix of each javascript file. It will load changes immediately which reduce lot of development time. Hope this helps all developers to speedup their development and clarify their concepts regarding share architecture.

Note: If you want to create your minified javascript file for deployment you can do it either online through http://jscompress.com/ or through many utilities of java. There are several JavaScript compressors out there like YUI Compressor. You can drop the JAR into your project and then invoke it from Ant quite easily.

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight

mitpatoliya

mitpatoliya

I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

2 Comments on Alfresco Share min.js File and Dependency Cache

  1. To enable web resources to be minified using maven, just add this to your pom.xml file.

    net.alchim31.maven
    yuicompressor-maven-plugin
    1.4.0

    alfresco/**/*.*
    **/*-min.js
    **/*.css

    compress-js

    compress

Leave a Reply

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


7 × = 21

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>