0

I'm new in Sitecore and i need to know how to manage the styling and javascript files for the controls.

I have a control that can be many times on the website, so if i place the bundle on the cshtml view, the bundle will be repeated the times the control is on the page. This takes me to place the bundle on the main view, but if i do that and the control is not on the page, the bundle will be load without any use of it.

What's the best approach to manage this?

0

Include all of your style and script bundles in the Main Layout. Have as few bundles as possible to limit the number of requests that the client needs to make. They will all be cached on the client during the first load and be available wherever they are needed going forward.

  • I understand that and was mi first approach. but there's no way to know what controls are on the page to know what bundles are needed to be load? – Phoenix_uy Feb 7 '17 at 19:57
  • there is a way to know what controls are on the page, but I would not recommend doing component-specific bundles. Very little will be gained as you'll be adding more individual requests for the client to make in order to make each request a little bit smaller. Browsers have a maximum simultaneous connections that they can make, typically 6. The more you have the longer it will take for the page to load. (stackoverflow.com/questions/985431/…) – Nathan Hase Feb 7 '17 at 22:03

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