0

I have several search results web parts on my page that all use custom display templates. Upon doing some performance testing I'm seeing several js files being loaded that aren't needed and I'd like to prevent them from coming through.

Is it possible to prevent these from loading? I looked through all the group and control templates and don't see any reference to them.

enter image description here

1 Answer 1

1

The Search Result web part has a set of pre-loaded display templates. So that is the reason you see templates get loaded that aren't necessary.

The list of pre-loaded templates is the following:

"~sitecollection/_catalogs/masterpage/Display Templates/Search/Group_Default.js",
"~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js",
"~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Site.js",
"~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Word.js",
"~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_PowerPoint.js",
"~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Person_CompactHorizontal.js",
"~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_BestBet.js",
"~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_WebPage.js"

These templates can be defined with a web part property called: PreloadedItemTemplateIds. This property is not available in the UI, so you need to export the web part and update the PreloadedItemTemplateIds element and upload it back to the site.

Before:

<property name="PreloadedItemTemplateIdsJson" type="string">["~sitecollection/_catalogs/masterpage/Display Templates/Search/Group_Default.js","~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js","~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Site.js","~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Word.js","~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_PowerPoint.js","~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Person_CompactHorizontal.js","~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_BestBet.js","~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_WebPage.js"]</property>

After:

<property name="PreloadedItemTemplateIdsJson" type="string">[]</property>

Important: you need to leave the brackets, if you remove them, the web part will load a hard coded list of display templates (which is just the same as the default property setting).

1
  • you could also do it using Powershell Jun 24, 2015 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.