Skip to content

that scripts are moved to head, will lead to a fetal erorr with inline script depends on the script files. #478

Closed
@dallaslu

Description

@dallaslu

the pjax response content:

<script src="/js/test.js">
</script>
<script>
    alert(Test.test());
</script>

the test.js:

var Test = {
    test: function(){
    return "Testing!";
    }
}

At first, Pjax will parse html content and run the inline script with 'eval', but the test.js hasn't been load because it is removed from the content and will be added to head later. The console prints 'Test' is undefined, and so, test.js will be never added to head, that means the object Test will always be undefined.

Script tags with src attribute are not all javascript libs only with object defined in it, they could contain some lines which is executable, and should run when loaded every time for the pjax response content.

Moving all scripts with src attribute to head is a kind of idiot behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions