andrewdavey/cassette — Issue #122: Duplication in asset references
Author: danfma
Created: 2011-12-25 07:44:05+00:00
State: open

# Scenario

The problem is simple. Let me say that I have the following configuration for the page:

```html

@ViewBag.Title

@Bundles.RenderStylesheets()
@Bundles.RenderScripts("head")
@Bundles.RenderHtmlTemplates("head")

@RenderBody()

@Bundles.RenderHtmlTemplates()
@Bundles.RenderScripts()

```

There are some scripts that must be rendered in the head, like: **jquery**, **jquery.ui** and **jquery.tmpl**. Additionally, I have some templates and others scripts that will be rendered in the end of the body.

# The problem

If I reference some script **App.js** that references back the **jquery**, then **jquery** will have its reference repeated in the body, because it was already added in the head. Then it could be skipped.

It's not really a problem, because the page will continue to work, but we will be loading twice the same file in the browser, which will be an unnecessary work for the it.

# Solution

Separate and filter the later scripts references by maintaining a cache of rendered filenames.