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.

There was a problem

You must be a member of this account.

PATCH: Allow Envjs.[before|after]ScriptLoad to capture all embeddedJS, not just external src

#110

Hola,

I'm not quite sure how to attach a patch, but this patch is 100% backwards compatible.

The current [before|after]ScriptLoad only allows you to intercept externally loaded files. My requirements is that sometimes I need to intercept embedded (inline?) scripts tags (i.e. those with no src).

The following patch is 100% backwards compatible but calls [before|after]ScriptLoad.

So you can do stuff like:

    var printAll = function(script) {

    if (script.src) {
        print("loadings... " + script.src);
    } else {
        print("inline: " + script.text);
    }
};



Envjs({
scriptTypes: { 'text/javascript': true },
beforeScriptLoad: { "^.*$": printAll },



});

The commit is:

commit  9d5bdb6accb90a9668ec639fe5b4a26f641c2778
tree    406f4b1bea66bcc796bb8ab66a6ba2853f1e82e9
parent  ff17aaf183275f8ceb4327c6203d6a51a85b6ec7

Sadly, the diff isn't particularly illuminating. Might just be best to look at the new change.

Reported by nickg · March 15th, 2010 @ 11:12 AM

State: new
Milestone: none
Assigned to: Thatcher Thatcher

Activity

  1. nickg
    nickg

    wow github must have a wiki bug.

    March 15th, 2010 @ 11:14 AM

  2. nickg
    nickg
    • Assigned user set to Thatcher

    giving to thatcher to approve or deny patch.

    March 15th, 2010 @ 07:27 PM

  3. Thatcher
    Thatcher

    ok, I'll buy this, the question is how to best implement it. Envjs can
    make sure all script evaluations internally are managed from a single point,
    we are actually relatively close, just need to include attribute event
    callbacks like onclick=''.

    We could then provide a default '' (inline) implementation and allow the
    user to change it. Event attribute callbacks may not fit as well but I'm
    all ears.

    March 16th, 2010 @ 05:02 PM

  4. nickg
    nickg

    Hmm, right. I was thinking more of true script nodes, and not callbacks in attributes.

    The first (and probably dumb way) would be to create a owner-less callback

    If we are talking about a new API that might deprecate the current ones, then, I defer until tomorrow!

    March 16th, 2010 @ 05:21 PM

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.