v2.6.0.10 doesn't load Javascript and CSS

Jun 18, 2012 at 7:54 PM

Hi friends,

I installed BE 2.6.0.10 and it doesn't load file in Scripts and in Styles folders.

How can I fix it?

 

Thanks in advance, have a nice day.

Bye

Coordinator
Jun 19, 2012 at 4:51 AM

Not sure why it doesn't load for you. Are you using IIS6 by any chance? Anyway, latest code has a setting to enable/disable optimization (admin/settings/advanced/enable optimization). When disabled, System.Web.Optimization is not used and plain styles/scripts loaded instead. Give it a try and see if it will help.

Jun 19, 2012 at 10:04 PM

I'm using IIS7, but I didn't find how to enable/disable this setting.

This is the portion of <head>

 

<!DOCTYPE html>
<html>
<head profile="http://gmpg.org/xfn/11"><meta charset="utf-8" />
<title>
Gianni Mariani | Presepio Artistico Monumentale di Casperia
</title>
<link rel="stylesheet" href="themes/Presepio/css/production.css" type="text/css" /><link rel="shortcut icon" href="pics/blogengine.ico" type="image/x-icon" />
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://www.giannicolas.it/themes/Presepio/Scripts/jquery.snowstorm.js"></script>
<meta name="keywords" content="casperia presepio presepe artistico monumentale giannicola mariani" />
<meta name="description" content="Presepio Artistico Monumentale di Casperia realizzato da Giannicola Mariani" />
<link rel="contents" title="Archive" href="/archive.aspx" />
<link rel="start" title="Gianni Mariani" href="/" />
<link type="application/rdf+xml" rel="meta" title="SIOC" href="http://www.giannicolas.it/sioc.axd" />
<link type="application/apml+xml" rel="meta" title="APML" href="http://www.giannicolas.it/apml.axd" />
<link type="application/rdf+xml" rel="meta" title="FOAF" href="http://www.giannicolas.it/foaf.axd" />
<link type="application/rss+xml" rel="alternate" title="Gianni Mariani (RSS)" href="http://www.giannicolas.it/syndication.axd?format=rss" />
<link type="application/atom+xml" rel="alternate" title="Gianni Mariani (ATOM)" href="http://www.giannicolas.it/syndication.axd?format=atom" />
<link type="application/rsd+xml" rel="edituri" title="RSD" href="http://www.giannicolas.it/rsd.axd" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="/Styles/css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/it-it.res.axd"></script>
<script type="text/javascript" src="/Scripts/Header/js"></script>
<script type="text/javascript" src="/Scripts/js" defer="defer" async="async"></script>
<link type="application/opensearchdescription+xml" rel="search" title="Gianni Mariani" href="http://www.giannicolas.it/opensearch.axd" /></head>

 

Notice that I added jquery manually otherwise it doesn't work.

Thanks a lot

Coordinator
Jun 19, 2012 at 10:36 PM

By the latest I meant code committed after 2.6.0.10, sorry didn't clarify it. That fragment you posted shows that scripts are included in the header, but I'm guessing you getting "not found" on each of them.

The way it supposed to work is script registered within Global.asax with optimization component as for example "Scripts/Header/js". Then System.Web.Optimization replaces that registered placeholder with all scripts found inside Scripts/Header folder or other scripts added to the bundle in Global.asax.

Clearly it doesn't work for you. Usually it happens with IIS6 - it can't handle extension-less URLs without some special treatment. It could be that IIS7 missing a module required to process such request, not sure. In any case, source code from 2.6.0.11 and up has a switch to turn optimization on and off so with "off" you should get normal ".js" or ".css" included in the header instead of virtual URLs pointing to bundled resources. That might help to solve your issue.

Jun 20, 2012 at 6:12 AM

I'm having a similar problem... I'm trying to load extra .js scripts in my theme but 2.6 adds jQuery to the very bottom of the head... all calls to jquery in scripts included in the head of site.master fail as they are out of order in 2.6 now. In 2.5 we could just include the js scripts in the theme name folder and they were added after jquery. 

The only way I can get it to work in 2.6 is by adding the scripts to the body instead of the head. 

I suspect that's the problem with the post above as well... (his call to jquery.snowstorm.js failed without him adding jquery above it as blogengine now puts it at the very bottom of the head). I'm not thinking it has anything to do with with IIS or css optimization.

 

We need a way to add the script to the theme name dir and have it load below the jquery... I would think this version would break any lightbox script etc. that relied on jQuery to be loaded first. 

Any ideas how to get around this besides adding the scripts to the body?

thx.

Coordinator
Jun 20, 2012 at 3:07 PM

The easiest way to add script to the /scripts folder instead of theme header. All scripts in the /scripts loaded in alphabetical order, this is why some prefixed with 01, 02 etc. Scripts in the /scripts/header loaded first and not differed. The latest code (2.6.0.11) fixes issue with theme styles by adding Global.css at very top, before any theme styles -  I guess we need do the same with "global" scripts, I'll check this out.

Jun 20, 2012 at 4:18 PM
rtur wrote:

The easiest way to add script to the /scripts folder instead of theme header. All scripts in the /scripts loaded in alphabetical order, this is why some prefixed with 01, 02 etc. Scripts in the /scripts/header loaded first and not differed. The latest code (2.6.0.11) fixes issue with theme styles by adding Global.css at very top, before any theme styles -  I guess we need do the same with "global" scripts, I'll check this out.

If your script is part of your theme then it makes it pretty hard to distribute as we only want to add the script to the theme folder... unless there is some way to ship the script with the theme and put it in the scripts folder... then when the user changes themes the script is still in the scripts folder and is still loading (that doesn't work either). BE needs to put the scripts after the css but before the scripts listed in the site.master head... or... some other way?

thx.

Coordinator
Jun 20, 2012 at 7:54 PM

Well, you can add script to the /scripts folder in the nuget package same as you adding theme to the /themes folder and distribute it through the gallery site. That will work fine and install properly, when uninstalled it will also be removed from /scripts. Problem is that when you have multi-blog site with dozens themes for users to choose from and they add lots of scripts, they all will be used no matter what theme is current. So it doesn't scale very well, and isolating theme assets to the theme folder is better option. Meaning yes we need to fix adding global scripts before theme scripts.

Jun 22, 2012 at 10:41 PM

Adding the scripts to the scripts folder wasn't a great idea anyway but even when I did they were not included? I put them in the /scripts folder and even tried in the /scripts/header folder and even named them after with the numbers in front and they still don't work. It doesn't seem to pick up the scripts I'm adding to the scripts folder at all? 

My only work around is putting them into the custom code field as this ends up under the jQuery... it works for me but yuk... can't distribute that. 

I had a quick look at the AllTuts theme and it's broke now also in 2.6 with the same problem (jQuery is not defined). Not sure how many others used some jQuery. 

Jun 22, 2012 at 10:47 PM
ildrago wrote:

Hi friends,

I installed BE 2.6.0.10 and it doesn't load file in Scripts and in Styles folders.

How can I fix it?

 

Thanks in advance, have a nice day.

Bye

 

Take those javascript lines back out of your site.master add this line to your custom code for now and it should work:

<script src="http://www.giannicolas.it/themes/Presepio/Scripts/jquery.snowstorm.js"></script>

Jun 23, 2012 at 2:21 PM

Hi guys!

I done this: 1st installed Microsoft.Web.Optimization via NuGet, and it load the .js in the Script folder; 2nd I added jquery.snowstorm.js and other .js using Setting > Custom Code.

Do you think could be possible create a feature that use a sub folder in a theme (named Script or Javascript , and CSS o Stylesheet) to load proper files only for that theme?

Thanks again, bye!

Jun 24, 2012 at 8:31 PM
Edited Jun 24, 2012 at 8:32 PM

BE 2.5.0.8 : My theme loaded flashobject.js / swfobject.js to display animations in the following way  :

// site.master
<head runat="server">
 <script src="<%# ResolveUrl("~/themes/MyTheme/flashobject.js") %>" type="javascript" />
</head>

BE 2.6.0.13 : Only way I have found to get flashobject.js executed was to copy flashobject.js into Scripts\Header folder and to disable optimizations in advanced settings.

Is there any other way,  would like to use optimizations ?
Also I had to comment <staticContent> in web.config so that site content is displayed correctly upon page refresh.

Win7 / IIS 7.5 / BE 2.6.0.13 SQLite, Single Blog
 

 

 

 

 

 

 

Jul 19, 2012 at 5:45 PM
mvincic wrote:

BE 2.6.0.13 : Only way I have found to get flashobject.js executed was to copy flashobject.js into Scripts\Header folder and to disable optimizations in advanced settings.

This seems to be true with 2.6.0.18 but it only works when logged in as the Admin, or at least when I can get to the dashboard.