Re: [JSMentors] Extensions on objects like c#

2011-03-05 Thread Peter van der Zee
On Sat, Mar 5, 2011 at 11:04 PM, Tom de Koning wrote: > > Hi all, > > I have been working with JS for quite a while, but coming from a .Net > background. I was wondering if it is possible to do something like > this in JavaScript: > > var expected = 5; > > var result = sut.somemethod(param1); > re

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread fernando trasvina
if you have something were you have that much control you should take a look on how other systems like YUI and labjs (i guess) declare dependencies and make your system to read them and include them in the right order. i would really like to hear on this matter because when packages get too big i

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Peter Michaux
On Sat, Mar 5, 2011 at 2:01 PM, fernando trasvina wrote: > In my process i configure one file that has the list of the files on the > packages. > > in the company i currently work we use ruby > > so we have a yaml file as the config file for jammit (the gem that packages > the files) Thanks for

[JSMentors] Extensions on objects like c#

2011-03-05 Thread Tom de Koning
Hi all, I have been working with JS for quite a while, but coming from a .Net background. I was wondering if it is possible to do something like this in JavaScript: var expected = 5; var result = sut.somemethod(param1); result.shouldEqual(expected); Now, the key thing is that I'd like to have

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread fernando trasvina
In my process i configure one file that has the list of the files on the packages. in the company i currently work we use ruby so we have a yaml file as the config file for jammit (the gem that packages the files) we list all the files and its dependencies manually (this file is only updated

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Peter Michaux
On Sat, Mar 5, 2011 at 1:20 PM, fernando trasvina wrote: > yes  that could be one idea i think that some of of the previously posted > libraries are good doing that, but i would go with a minifier on the server > rather than downloading files separately > you can even mix the files to create dif

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread fernando trasvina
yes that could be one idea i think that some of of the previously posted libraries are good doing that, but i would go with a minifier on the server rather than downloading files separately you can even mix the files to create different packages for special needs you may have. On Mar 5, 2011,

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Rob Griffiths
I meant 20kb and I was thinking of minified js only On 5 Mar 2011, at 20:56, Peter Michaux wrote: > On Sat, Mar 5, 2011 at 10:38 AM, Rob Griffiths wrote: > >> I tend to pack together files if they are < 2k its not worth the overhead of >> a http request to load each file separately. > > Would

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Peter Michaux
On Sat, Mar 5, 2011 at 10:38 AM, Rob Griffiths wrote: > I tend to pack together files if they are < 2k its not worth the overhead of > a http request to load each file separately. Wouldn't the cutoff be much higher than 2 kB? Given the size of image files that are probably in the page, I'd think

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Ryan Grove
On Sat, Mar 5, 2011 at 12:32 PM, Jarek Foksa wrote: > What's wrong with my original loadScript() function? I was scratching > my head for several hours but I still don't get it why it doesn't work > correctly on Safari. What's happening is that when scripts are dynamically injected, browsers do

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Jarek Foksa
> you can do that trough ajax, using a wait function to load the > scripts in order, but going other way with this. I could read the files in proper order with XMLHttpRequest(), then merge them into one variable and finally print them between tags. Is that what you meant? var mergedScripts = "";

[JSMentors] client-side development environment

2011-03-05 Thread Peter Michaux
Hi All, Lately I've been thinking about my client-side development environment, the organization of the source files, how the files are built (e.g. concatenated and minified) and how I specify which files will be concatenated together during the build. Also the same for CSS files and joining image

Re: [JSMentors] What are the alternatives to "var self = this"?

2011-03-05 Thread Ivan Kalyaev
Hi, Patrick Mueller of IBM has an interesting blogpost on "bind". http://pmuellr.blogspot.com/2010/06/bind-considered-harmful.html -- С уважением, Иван 04.03.2011, в 14:14, Jarek Foksa написал(а): > Woah, thanks for fast replies. I wasn't aware that there are so many > ways to do this in JS.

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Rob Griffiths
You might try LABjs http://labjs.com/ or HeadJS http://headjs.com/ Both are script loaders, and handle order or loading and execution of external script files. of course if you control the external javascript files, it would be much better to concatenate the files together, unless of course they

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread Bill Heaton
Jarek, If you are using PHP on your server you my be interested in Minify I have recently started using Minify -> http://code.google.com/p/minify/ which helps to group (package) sets of js files for specific functionality and also minify for performance sake too. (Less http requests and sma

Re: [JSMentors] Loading .js files dynamically

2011-03-05 Thread fernando trasvina
you can do that trough ajax, using a wait function to load the scripts in order, but going other way with this. why do you load files that way if I may ask? that approach is kinda slow if you know you need those scripts why don't you use one js packager On Mar 5, 2011, at 11:46 AM, Jarek Foks

Re: [JSMentors] Re: What are the alternatives to "var self = this"?

2011-03-05 Thread fernando trasvina
i would go to not aliasing the "this" variable unless you want a closure to have access to the original this, like when passing a function to an event handler other than that it seems that you are making up a generalization based on fear. On Mar 5, 2011, at 10:47 AM, Michael Haufe (TNO) wrote:

[JSMentors] Loading .js files dynamically

2011-03-05 Thread Jarek Foksa
Let's say that I have four scripts: init.js, script-1.js, script-2.js and script-3.js. Only init.js is declared in XHTML file, the other three scripts are loaded from init.js. The code for each file is as follows: init.js function loadScript(url

[JSMentors] Re: What are the alternatives to "var self = this"?

2011-03-05 Thread Michael Haufe (TNO)
An alternative is not to write code that way to begin with so there won't be an issue with shadowing and extraneous function objects: function Dialog(width){ this._width = width; } Dialog.prototype = { constructor : Dialog, setWidth : function(width){ this._width = width; }

Re: [JSMentors] What are the alternatives to "var self = this"?

2011-03-05 Thread Peter van der Zee
On Sat, Mar 5, 2011 at 4:56 PM, אריה גלזר wrote: > I like $this personally - it is closest to original meaning, and has an > additional bonus that some editors (such as vim) highlight it properly > And I'd immediately think it would a jquery|framework object. We're not doing php... (I prefer `t

Re: [JSMentors] What are the alternatives to "var self = this"?

2011-03-05 Thread אריה גלזר
I like $this personally - it is closest to original meaning, and has an additional bonus that some editors (such as vim) highlight it properly On Sat, Mar 5, 2011 at 3:34 PM, Lasse Reichstein wrote: > On Thu, 03 Mar 2011 20:08:33 +0100, Jarek Foksa > wrote: > > When writing constructor functio

Re: [JSMentors] Diagnosing Sluggishness in IE9 RC?

2011-03-05 Thread Balázs Galambosi
On Thu, Mar 3, 2011 at 5:16 PM, Busticated wrote: > Hi all - >    I'm hoping to get some pointers on how I can track down the cause > of gui slowness in IE9 RC. Some quick background: The app is fairly JS- > heavy... lot's of ajax and fancy gui interactions... i'm using jquery > (1.4.4 at the mome

Re: [JSMentors] What are the alternatives to "var self = this"?

2011-03-05 Thread Lasse Reichstein
On Thu, 03 Mar 2011 20:08:33 +0100, Jarek Foksa wrote: When writing constructor functions it's very convenient to create "var self = this" assignment so that we could easily access other properties and methods even if default context has changed, for example: var Dialog = function() { var

Re: [JSMentors] Re: Diagnosing Sluggishness in IE9 RC?

2011-03-05 Thread Sergio Cinos
What I usually look for in the Profile: - Identify functions with biggest excl. time and try to optimize them - Same for functions that are executed a lot of times - Identify functions with a big difference between total time and excl. time. It usually means that the function is doing something co