#110 new

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

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


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);

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.

Comments and changes to this ticket

  • nickg

    nickg March 15th, 2010 @ 11:14 AM

    wow github must have a wiki bug.

  • nickg

    nickg March 15th, 2010 @ 07:27 PM

    • Assigned user set to “Thatcher”

    giving to thatcher to approve or deny patch.

  • Thatcher

    Thatcher March 16th, 2010 @ 05:02 PM

    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.

  • nickg

    nickg March 16th, 2010 @ 05:21 PM

    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!

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

a javascript browser environment

People watching this ticket