Request.processScripts always evals .js files. #2220

ibolmo opened this Issue Jan 19, 2012 · 2 comments


None yet
2 participants

ibolmo commented Jan 19, 2012

(from Lighthouse)

processScripts: function(text){
    if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return $exec(text);
    return text.stripScripts(this.options.evalScripts);

After a little trip to the Request class I realized that all js files are being exec. Is there any reason why you are imposing this? We have the option of exec something that is NOT js but we DONT have the options of NOT exec something that is js??? Is it possible you guys can rework the class or give us an extra option for this?

(from comment)

Im working on a "desktop app" that runs in the browser... it is fetch from a server (not necessarily from the internet, in most cases the server is in an embedded device) and we want to prefetch scripts at a certain time but not execute them up front. Scripts must be managed later when they are needed due to the nature of the project (but they must have been loaded and stored already). The scripts will be eval but we are the ones that will decide when.

Anyhow I think the code should give the user the flexibility to choose whether the scripts get executed or not.


ibolmo commented Jan 19, 2012

See also:


I tried to use Request for some ajax content insertion (Request.HTML did no better). When the answer contained a javascript captcha it was removed when I inserted the html (via innerHTML = ...).

I had the choice between evalRequest and evalScripts to change this behaviour. evalRequest did what I want in Firefox and Safari:

It left the script tags in place so that I could do some magic to get them working again (innerHtml assignments don't really work with scripts).

However - this evaluated the whole response which failed in Chrome because the response did contain html and not javascript. What I really wanted was something like evalScripts=false which leaves the script tags in place.

    processScripts: function(text){
        return text;

Did the trick for me but I think there should be another flag or something.


  • CH

fakedarren commented Jul 28, 2012

We can't change this in case this is expected behaviour.

If there's a pull request to go with it then we can re-open this.

@fakedarren fakedarren closed this Jul 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment