Granite JS and CSS files loaded twice | Community
Skip to main content
Level 2
October 16, 2015
Solved

Granite JS and CSS files loaded twice

  • October 16, 2015
  • 3 replies
  • 1744 views

When a page (http://localhost:4502/content/geometrixx/en.html) is opened in author mode with content finder, JS and CSS files are loaded twice.

Granite, foundation, personalization JS and CSS files.

e.g /etc/clientlibs/granite/jquery/granite.js

/etc/clientlibs/foundation/shared.js

/etc/clientlibs/foundation/personalization/ui.js) 

Is there any workaround to prevent these files from loading twice.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Runal_Trivedi

Hi Jitendra,

As far as I know there is no way to avoid it from happening.

First of all let me explain you why it happens:

  •  When you load the page with contentfinder then your actual page gets loaded in iframe, so if you access URL - localhost:4502/cf#/content/geometrixx/en.html then content/geometrixx/en.html is loaded in a separate iframe in your page document (You can validate that using firebug).
  •  Now when you load content finder the HTML gets rendered from following script - /libs/cq/ui/components/widget/html.jsp
  •  This HTML will load its own set of clientlib categories defined on node - /libs/wcm/core/content/contentfinder with property jsLibs and then using extjs is creates IFrame on the fly using the page path accessed.
    • the value present right now is cq.wcm.edit
  • cq.wcm.edit further includes all the other libraries and their respective js/css that you are seeing twice (You can validate that using dumplib url - http://localhost:4502/libs/granite/ui/content/dumplibs.html?categories=cq.wcm.edit&type=JS&theme=, see the snapshot below)
  • [img]cq.wcm.edit.jpg[/img]
  • And finally since the page is actually loaded via Iframe, it again injects its own clientlibs defined in its head section (go to firebug HTML console and search for head tag, you should see two head tags present)

 Thanks
 Runal

3 replies

Runal_Trivedi
Runal_TrivediAccepted solution
Level 6
October 16, 2015

Hi Jitendra,

As far as I know there is no way to avoid it from happening.

First of all let me explain you why it happens:

  •  When you load the page with contentfinder then your actual page gets loaded in iframe, so if you access URL - localhost:4502/cf#/content/geometrixx/en.html then content/geometrixx/en.html is loaded in a separate iframe in your page document (You can validate that using firebug).
  •  Now when you load content finder the HTML gets rendered from following script - /libs/cq/ui/components/widget/html.jsp
  •  This HTML will load its own set of clientlib categories defined on node - /libs/wcm/core/content/contentfinder with property jsLibs and then using extjs is creates IFrame on the fly using the page path accessed.
    • the value present right now is cq.wcm.edit
  • cq.wcm.edit further includes all the other libraries and their respective js/css that you are seeing twice (You can validate that using dumplib url - http://localhost:4502/libs/granite/ui/content/dumplibs.html?categories=cq.wcm.edit&type=JS&theme=, see the snapshot below)
  • [img]cq.wcm.edit.jpg[/img]
  • And finally since the page is actually loaded via Iframe, it again injects its own clientlibs defined in its head section (go to firebug HTML console and search for head tag, you should see two head tags present)

 Thanks
 Runal

smacdonald2008
Level 10
October 16, 2015

Are you using AEM 6?

Level 2
October 16, 2015

We are using AEM Version 5.6.1.20130606