Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:45:36+00:00 2026-06-07T17:45:36+00:00

I have the following piece of code that emits all my javascript: @using SquishIt.Framework.Minifiers.JavaScript

  • 0

I have the following piece of code that emits all my javascript:

@using SquishIt.Framework.Minifiers.JavaScript
@{
    string[] scriptLinks = new[]
    {
        Url.Content("~/content/script/json2.js"),
        Url.Content("~/content/script/b.extensions.js"),
        Url.Content("~/content/script/jquery.extensions.js"),
        Url.Content("~/content/script/jquery.validate.min.js"),
        Url.Content("~/content/script/jquery.validate.unobtrusive.min.js"),
        Url.Content("~/content/script/jquery.validate.tooltip.js"),
        Url.Content("~/content/script/jquery.form.js"),
        Url.Content("~/content/script/jquery.placeholder.js"),
        Url.Content("~/content/script/jquery.tooltip.js"),
        Url.Content("~/content/script/jquery.signalr-0.5.2.js"),
        // TODO: Url.Content("~/signalr/hubs"), // SignalR auto-generated hubs proxy ? Get Programatically??
        Url.Content("~/content/script/b.core.js"),
        Url.Content("~/content/script/b.facebook.js"),
        Url.Content("~/content/script/b.twitter.js"),
        Url.Content("~/content/script/b.realtime.js"),
        Url.Content("~/content/script/b.init.js"),
        Url.Content("~/content/script/views/user/login.js"),
        Url.Content("~/content/script/views/post/create.js"),
        Url.Content("~/content/script/views/post/list.js")
    };
}
@{
@* we don't bundle external javascript links nor localization messages. *@
    const string jQueryVersion = "1.7.2";
    string jQueryExternal = "//ajax.googleapis.com/ajax/libs/jquery/{0}/jquery.min.js".FormatWith(jQueryVersion);
    string jQueryLocal = @Url.Content("~/content/script/jquery-{0}.min.js".FormatWith(jQueryVersion));
}
<script src="@Url.Action("Localization", "Resource")"></script>
<script src="@jQueryExternal"></script>
<script>!window.jQuery && document.write(unescape("%3Cscript src='@jQueryLocal'%3C/script%3E"))</script>
@(Bundle.JavaScript()
    .Add(scriptLinks)
    .WithoutTypeAttribute()
    .WithMinifier<YuiMinifier>()
    .WithConfiguration()
    .MvcRender("~/all.js?_=1")
)
@JavaScript.Emit()
@* TODO: analytics service (pixel goes to noscript partial) *@

This always works just fine except the scenario where I remove the external jQuery reference to the google cache: <script src="@jQueryExternal"></script> AND the rest of the scripts are minfied in a single script tag.

I also figured out that if I added any script tag after the document.write tag, such as this:

<script>!window.jQuery && document.write(unescape("%3Cscript src='@jQueryLocal'%3C/script%3E"))</script>
<script></script> @* work around an issue where javascript minified into a single script tag won't find references to jQuery if loaded in the previous script tag. *@

It does work.

Otherwise I get a “anything is undefined”

Tested in both chrome 20 and firefox 11, so what’s that extra, empty script tag, doing exactly? and why does it mitigate this corner-case error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:45:38+00:00Added an answer on June 7, 2026 at 5:45 pm

    turns out the issue was in the document.write element being improperly closed.

    unescape("%3Cscript src='@jQueryLocal'%3C/script%3E")
    

    into

    unescape("%3Cscript src='@jQueryLocal'%3E%3C/script%3E")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following piece of code : public Hashmap<String,String> tempmap = new HashMap<String,String>(); and
I have the following piece of code that finds all elements in the document
I'm using GTMLogger and have the following piece of code that seems to be
I have the following piece of code (that may be invoked multiple times or
I have the following piece of code that I'm expecting to run on a
I have the following piece of code that works well in Windows Server 2003.
I have the following piece of SQL code that does the following: Obviously looks
I have the following piece of code that is taken from a mock exam
I have written the following piece of code that reads through a given xml-file
I have the following piece of code (only relevant parts): xhttp=new XMLHttpRequest(); xhttp.open(GET,doc_name,false); xhttp.send();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.