Trying to apply bundling to scripts, which worked fine when were located at pages in old way (manually).
This is bundles registration:
Bundle sbundle = new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/menu-correction.js",
"~/Scripts/validation-rules.js",
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/jquery.validate*");
bundles.Add(sbundle);
bundles.Add(new ScriptBundle("~/bundles/session").Include(
"~/Scripts/jquery.plugin.js",
"~/Scripts/jquery.countdown.js",
"~/Scripts/session-management.js"));
//others
Then in Layout page call:
#Scripts.Render("~/bundles/jqueryval")
#Scripts.Render("~/bundles/session")
But when minification is become enabled, i got this errors in chrome console:
Uncaught SyntaxError: Unexpected identifier jqueryval:1
Uncaught SyntaxError: Unexpected identifier session:1
Also i can see my scripts in tab page "Sources" of chrome developer tools - they are minificated successfully. Spent enough time trying to fix this. What can be a reason of this mistake?
Thanks in advance.
I provided insufficient information: there is some logic in Application_PostRequestHandlerExecute method which wrotes some tags directly to response stream (is needed for js). I noticed that tags which were written directly in response stream with bundling is being written actually in the end of minificated js file.Thus, syntax is broken and js file doesn't work (Without bundling my approach works fine).
Solution: transferred my logic from Application_PostRequestHandlerExecute to Application_AuthorizeRequest method, where it should was located initially.
UPDATE
Well, tag generating logic was entirely removed from Application_PostRequestHandlerExecute method, cause only now i understand that this is absolutely wrong idea.
Related
My problem is exactly like this one:
https://github.com/mrdoob/three.js/issues/4639
While debugging my js app in WebStorm, every JSON from XMLHttpRequest response is annotated with:
//# sourceURL=http://localhost:63342/JSON_URL_here
This doesn't happen while debugging in Chrome with Jetbrains plugin deactivated, so I guess it's a fair bet that WebStorm is performing the annotation.
The problem is, the JSON file can't be parsed, throwing the following error:
Uncaught SyntaxError: Unexpected token /
Is it possible to solve this issue, other than changing the THREE source code and manually removing the problematic line?
sourceURL appended to any JS file loaded via XHR (jquery load script for example). Otherwise it is impossible to set breakpoint.
You should not use ".js" file extension for JSON files, please use ".json" instead. Is it possible in your case?
Strange error here: I have a page that's referencing several JavaScript files. Occasionally, the browser will complain of:
Uncaught SyntaxError: Unexpected end of input
However, it doesn't appear to be due to a missing parent, or malformed JSON. Part of the JavaScript file will load, but the program will just stop loading the rest of the file. Example: half of the file will load, with the other half missing.
Most of the time, the files load and everything works. Any idea why I would occasionally be getting this error, rather than every time (as expected with a missing paren or something similar)? Other things I can check?
EDIT:
This is a Rails project (Rails version 3.2).
The JS files are standalone, and are kept in the pub directory for dev. In other words, they are NOT included in the asset pipeline.
There must be braces not closed properly.The file stops loading whenever the error is encountered and leaves the rest part unloaded as because of error.
You can check this example here
I am doing an experimental HTML template wich comes with jquery.min.js file - one of the most popular javascript libraries.
When I load the template from my local hard drive it works fine.
When I upload it and load it from server (GWAN) I get error (I think is not the only one) in Chrome looks like this:
Uncaught SyntaxError: Unexpected token { jquery.min.js:3
I inspected a bit and realized there is a
function $
which was turned into
function$
by GWan. The space removed is causing an error in Chrome, Firefox and Safari. I haven't tested other browsers but my IDE also reports a syntax error in the downloaded from GWAN version of the JS file.
I have also tried uploading the files to another server (Apache) and no problem there. The js file was not modified...
Any clues on how to get over this? I suppose there is a bug in javascript on-the-fly optimization of GWan?
Thanks.
It's a known issue and it will be fixed in next release (soon)
You'll be able to disable minifying directly from a init.c script in G-WAN v4.10+, this way:
u8 *www_mini = (u8*)get_env(argv, USE_MINIFYING);
if(www_mini)
{
*www_mini = 0;
puts("> disable minifying");
}
You just have to wait for few days for the new v5 release.
I'm trying to put a Symfony 2 app in production mode. It all runs fine except for the fact that the compressed single JavaScript file causes errors and makes the site unable to render correctly. I found this through the debug console on the browser:
Uncaught TypeError: undefined is not a function
Uncaught TypeError: Object [object Object] has no method 'treeview'
The first error refers to jQuery plug-ins
The treeview refers to a plugin for jQuery which renders a tree like directory structure.
On the other hand, it all runs fine on dev mode cause it doesn't do the compression and it just includes every file one by one. Can someone help me on this one?
I've found a solution to this, it appears the issue is related to missing semi-colons.
When something is the last statement in a js file a semi-colon isn't required however assetic just joins the files together and only adds a new line.
Check the file which is being included just before the broken plugin javascript and make sure it ends with a semicolon.
I have dajaxice installed on my python2.6 dist-packages folder, that seems to work alright with importing the stuff. But it throws all kinds of errors, since the django template tags are not being rendered.
invalid property id [Break on this
error] {% for module in
dajaxice_js_functions %}\n
Makes sense, so I tried putting the js into HTML straight, which solves some of the problems of the templatetags, but gets messed up again, probably since its looking for dajaxice_core_loop.js
invalid property id
[Break on this error] ,\n
I kept on uncommenting JS that throws me errors, but here i stripped it down to an extent that it is not working at all (duh). Because when I recreate the example with the button and hit the button i get:
Dajaxice.MYAPP is undefined
of course, MYAPP is my specific application that holds the ajax.py
I guess I am doing it all wrong, but I can't really tell from the documentation what that might be specifically.
Found that I shoulnd't have configured that Nginx serves my js statically, resolved!
Quick note: on the Django development server I had to place the Dajaxice URL entry before the static media so it could parse the javascript correctly.