Currently, for every content type, css is embedded into the content type itself. Hence, css related to content type will only load when the content type is added into the page.
However, if you add more than one of the same content type in a page, it will load the css again and again.
Hi ,
Please find i have custom content type called Quicklinks , i have page where this content type used twice so the css repeating twice , How to avoid this ?
This is one of the reasons we use ClientDependency. Our websites have reusable components built around Archetype or Nested Content so each component has a Partial View and a CSS file and (sometimes) a JavaScript file. The CSS and JavaScript are loaded via ClientDependency which handles the de-duping for us.
For example, in a banner ads component the partial view (~/Views/Partials/Archetype/BannerAds.cshtml) would contain this:
Prevent css repetition in each content type
Hi all,
Currently, for every content type, css is embedded into the content type itself. Hence, css related to content type will only load when the content type is added into the page.
However, if you add more than one of the same content type in a page, it will load the css again and again.
So , this needs to be prevented.
Could you post screen dumps or code examples? As far as im aware no css is embedded in templates or partials per default...
Or are you talking about some kind of backend grid renderer...?
Hi , Please find i have custom content type called Quicklinks , i have page where this content type used twice so the css repeating twice , How to avoid this ?
Hi,
to give you an idea: You could write a method to avoid duplicate css. (Following is untested)
~ Jonathan
Hi Jonathan,
Thank you for the reply :)
This is my below the css and Js , these two items is repeating , how i can approach with the above one ?
Hi,
You can call it like this:
For javascript-files you can do the same.
You have to make sure that you have a single instance of the class containing the methods. Otherwise it won't work and the result will be the same.
~ Jonathan
Hi Jonnnathan,
What do you mean by single instance of class , Can you give an example from my above html code ?
This is one of the reasons we use ClientDependency. Our websites have reusable components built around Archetype or Nested Content so each component has a Partial View and a CSS file and (sometimes) a JavaScript file. The CSS and JavaScript are loaded via ClientDependency which handles the de-duping for us.
For example, in a banner ads component the partial view (~/Views/Partials/Archetype/BannerAds.cshtml) would contain this:
For more information check out: https://github.com/Shazwazza/ClientDependency
is working on a reply...