Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Execute scripts appended to DOM by code

#3

In addition to executing scripts on document load, we need to execute scripts that are dynamically generated in the document.

I added the following in appendChild:

    appendChild: function(node){
        this._dom.appendChild( node._dom );
        // BEGIN PATCH
        if (node.tagName == 'SCRIPT') {
            if (node.getAttribute("src")) {
            setTimeout(function() { load(node.src); },0);
            } else {
            setTimeout(node.textContent,0);
            }
        }
        // END PATCH
    },

This is a little too naive, though; we'd like the src attribute to load relative to window.location. This is more properly handled by the generic script executor (we may need to write some code to parse relative URLs).

Reported by Wes Biggs · January 2nd, 2009 @ 02:59 PM

State: resolved
Milestone: 1.0 Release
Assigned to: Thatcher Thatcher

Activity

  1. thatcher.christopher (at gmail)
    thatcher.christopher (at gmail)
    • State changed from new to open
    • Assigned user set to thatcher.christopher (at gmail)

    ok I added a new policy file that by default allows the scripts to be executed based on a policy.

    By default this is set to

    $policy.loadScripts = $env.safeScript;

    which will not execute any scripts other than those loaded through rhino.

    you can change this to

    $policy.loadScripts = $env.loadLocalScripts;

    This will load the scripts defined relative to the window.location or inline scripts.

    I didnt address loading of remote scripts yet but will do.

    This is in http://github.com/thatcher/env-js

    going to leave this open until remote scripts are addressed.

    https://github.com/thatcher/env-...

    January 19th, 2009 @ 09:16 PM

  2. thatcher.christopher (at gmail)
  3. Thatcher
    Thatcher
    • Tag set to client, loading, script, server, strategy, textenvjs, textjavascript
    • Assigned user changed from thatcher.christopher (at gmail) to Thatcher

    Still leaving this as open as we push to a 0.1 release.

    However I just committed what I think is the best script loading implementation yet. I took the advice from the original ticket post and load if the script ownerDocument is the window document. its loaded relative to window loacation . And as a precaution the scripts is currently only loaded in the type contains text/envjs but also supports ;-delimited types so you can have text/javascript;text/envjs.

    http://github.com/thatcher/env-j...

    February 1st, 2009 @ 04:27 PM

  4. Thatcher
  5. Thatcher

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.