/    Sign up×
Community /Pin to ProfileBookmark

Selection of inline scripts disappearing from one line to the other

Hello all,

I’ve been fighting around with this issue for a few days now, that’s why I’m raising this thread.

I’ve also researched the web in vain…
Maybe someone has run into something like this before…

Algorithm outline: (in the context of handling inline scripts – pseudo code)

Preconditions:

  • Fetch the HEAD and BODY of the target page into jQuery variables (head and body)

  • Filter out <links> and <scripts> in the HEAD (works)

  • Filter out <scripts> in the BODY with
  • [CODE]bjss = body.find(“scripts”);
    $s.t = bjss.filter(function() { return !$(this).attr(‘src’); });[/CODE]

    When debugging, I can see that

    $s.t correctly holds some inline scripts.

    Then call another function, that does not manipulate $s.t.

    In the final function call, that is supposed to handle the inline scripts,

    [CODE]$s.t[/CODE]

    …for some reason is empty:

    [CODE]($s.t.length==0)[/CODE]

    [B]How can a jQuery selection just disappear more or less from “one line to the next”?[/B]

    EDIT:

    [url]http://stackoverflow.com/questions/4644799/javascript-variables-are-disappearing[/url]

    It could be related to the above thread, as I’m passing back inner variables of “sub-plugins” up to its clients.

    But if that’s the case, I’d have to refactor the code heavily, as the same symptoms could arise anywhere it future randomly.

    The way I understood garbage collection in JavaScript, as long as there is a reference to data remaining, it is not collected?

    [B]What’s best practice for sharing data across function calls[/B]?

    Thanks in advance and
    Kind regards

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @arvgta spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.6,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...