# Distinguish generic mtc.js from dynamic mtc.js #4017

**URL:** https://forum.mautic.org/t/distinguish-generic-mtc-js-from-dynamic-mtc-js-4017/10279
**Category:** Ideas and Feature Requests
**Created:** [February 26, 2018, 2:46am UTC](https://forum.mautic.org/t/distinguish-generic-mtc-js-from-dynamic-mtc-js-4017/10279 "2018-02-26T02:46:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![npracht](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/npracht/32/240_2.png) [@npracht](https://forum.mautic.org/u/npracht)
#### Post date: [February 26, 2018, 2:46am UTC](https://forum.mautic.org/t/distinguish-generic-mtc-js-from-dynamic-mtc-js-4017/10279/1 "2018-02-26T02:46:00Z")

</div>

_Initially reported on [https://github.com/mautic/mautic/issues/4017](https://github.com/mautic/mautic/issues/4017)_

**Description:**  
The load of the mtc.js file is quite long on web browser. One of the opportunity to optimize that load, is to add a cache control to the mtc.js.

Unfortunately, there are small dynamic pieces in the mtc.js if the mautic user has web notifications, pages, (gated videos ?) and dynamic contents. Because of that, it is NOT possible to add the cache control.

**Recommandation**  
Create a core mtc.js that is ALWAYS the same and that includes a cache control.  
Create a “dynamic” script (eg: mtc\_dynamic.js) that includes variations hereabove which will be generated each time if needed.

**This optimization request has been +1 by many GH users.**

---

<div class="post-metadata">

### Author: ![andjules](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/andjules/32/342_2.png) [@andjules](https://forum.mautic.org/u/andjules)
#### Post date: [June 19, 2018, 10:57am UTC](https://forum.mautic.org/t/distinguish-generic-mtc-js-from-dynamic-mtc-js-4017/10279/2 "2018-06-19T10:57:09Z")

</div>

I agree. I’m new to Mautic and while overall I’m very excited about the possibilities, I quickly noticed mtc.js is ~135kb, when [drip.com](http://drip.com)’s is, for example, 41kb (and linkedIn’s, which admittedly only does basic tracking, is 13kb). I can probably deal with the size, but it would be great to separate base code so it can be better cached, and then have an advanced features aggregated .js file (I imagine checking the boxes of the advanced features I intend to use and getting the smallest features .js file that can support it).

---

<div class="post-metadata">

### Author: ![andjules](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/andjules/32/342_2.png) [@andjules](https://forum.mautic.org/u/andjules)
#### Post date: [June 21, 2018, 7:15am UTC](https://forum.mautic.org/t/distinguish-generic-mtc-js-from-dynamic-mtc-js-4017/10279/3 "2018-06-21T07:15:24Z")

</div>

p.s. for those interested in a minor hack, if you don’t use gated video (surely that’s a small minority), commenting out one line of code in `/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php`,  
`[‘onBuildJsForVideo’, 256],` (around line 56)  
as per [https://www.robertwent.com/blog/cutting-size-mautic-javascript-tracking-script/](https://www.robertwent.com/blog/cutting-size-mautic-javascript-tracking-script/)

Reduces mtc.js from ~135kb to ~49k  
But of course, you’ll need to re-do the hack after the each upgrade.

Obviously, creating a longer cache would be a great enhancement as well.

---

<div class="post-metadata">

### Author: ![andjules](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/andjules/32/342_2.png) [@andjules](https://forum.mautic.org/u/andjules)
#### Post date: [June 22, 2018, 6:25pm UTC](https://forum.mautic.org/t/distinguish-generic-mtc-js-from-dynamic-mtc-js-4017/10279/4 "2018-06-22T18:25:10Z")

</div>

One other hack that _seems to work_ (so far) is to load yourmautic/mtc.js in your browser, save it locally, then upload the file to (let’s say) /media/js and manually change the file request URL in your tracking code to reference yourmautic/media/js/mtc.js instead of yourmautic/mtc.js. As a static file (instead of a php request that generates and minifies on the fly), it loads much faster.

It would be great to see options to (a) exclude gated video code (and any other advanced features that could be optioned-out) and (b) generate a static file (maybe putting it in cache so that it is regenerated any time the cache is cleared?)

---

<div class="post-metadata">

### Author: ![adiux](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/adiux/32/5793_2.png) [@adiux](https://forum.mautic.org/u/adiux)
#### Post date: [February 10, 2021, 7:07am UTC](https://forum.mautic.org/t/distinguish-generic-mtc-js-from-dynamic-mtc-js-4017/10279/5 "2021-02-10T07:07:35Z")

</div>

Is there any documentation or code that tells us which parts need to be dynamic?
