AnsweredAssumed Answered

<@script> vs <script> in a foo.get.html.ftl

Question asked by davidraines on May 29, 2017
Latest reply on May 29, 2017 by davidraines

My project needs to use a moderately large (1.5MB) JavaScript library in both our login page, and in our regular pages once you've logged in.  When we've "naively" referenced this file from both places, its causing it to get downloaded twice.  Once it is downloaded by its normal name "example-library.js", the other time its downloaded with a serial extension ("example-library_0a0da13c6dc370802cb4c2dc6ef1f559.js").


I understand that the additional characters are there to help manage the browser caches.  However, this file changes very rarely, and we could just manually put a version number on it if we ever changed its version.  It is a 1.5MB file, however, and it causes about a 20% increase in our "download footprint" when its included twice.


Is there a way in an FTL file of the form "foo.get.html.ftl" to reference a file such that it doesn't get the serial number attached to its name?


We're using tags like this (these seem to be present in all the *.get.html.ftl files):

<@markup id="js">
<@script src="${url.context}/res/example-library.js" group="header"/>


I've tried replacing the "<@script>" tag with a "<script>" tag, but then the <script> reference winds up in the <body> of the generated HTML, not in its <head>, which causes other problems.


I've also tried to refactor our login page to reference the JS library *with* the serial numbers.  This was successful, but I had to #include the "alfresco-template.ftl" file, which included so much other extra JS and CSS resources, that it caused us to download even more files, and defeated the purpose (which is to manage / reduce the download footprint).


I'd appreciate any help.