Deferring contexthub.kernel.js



AEM version:

We are in the middle of making performance optimization on our site, as such we are deferring any and all JS scripts with `defer` attributes to prevent scripts from render-blocking. We are using contexthub so naturally, we see the following script:

<script src="/etc/cloudsettings/default/contexthub.kernel.js" type="text/javascript"></script>

We want to add the `defer` attribute to that script; looking at the JSP the renders this script: /libs/granite/contexthub/components/contexthub/contexthub.jsp we see that the only option is to overlay that JSP, which is not a great option especially if Adobe makes changes to that JSP in future releases.

Here are my questions:

  1. Are there any drawbacks to deferring contexthub.kernel.js? I.e. is it render-blocking for a good reason?
  2. I see that the contexthub.kernel.js has dependencies on other code like Granite.HTTP.externalize and I see in the codebase that those dependencies are included in a different clientlib. How are those dependencies included usually? I could not find any documentation around that. I assume that script should be dependency-free since it already includes jQuery and other stuff.

Any help is greatly appreciated. Thank you!






atyaf66​ and raghavc​ if possible, please open a support case with our AEM support team.  We can ask the Adobe engineering team why the contexthub kernel is loaded synchronously and if there is any optimization that can be done.




Response from Adobe

Loading contexthub script as non render blocking scripts is planned to be part of AEM 6.6 (GRANITE-20288)