You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Yes, pjax breaks this use case. Read #331 (comment) and subsequent comments for more information. However, we can't fix this within pjax completely for all sites out there because the browsers don't let us execute dynamically inserted scripts in order if Content Security Policy is turned on and eval is forbidden. This is the primary reason we're moving all script[src] to <head> and not supporting other inline scripts.
We would welcome your suggestion for a solution that:
Is not "idiot" by your standards; and
that also works on CSP-enabled sites such as GitHub.com.
Thank you for your prompt reply and patiently explained. First, this method does not work in many cases. It wasted a lot of my time to the debugger. Prior to finding the perfect solution, and it should be removed off, or optional, according to the properties such as script tags to decide whether to move to the head.
I agree that 'construct your external script tags to not depend on each other at eval time', but can't agree that 'handle script loading manually in your app using pjax events'. Pjax should be a non-invasive improvement, it shouldn't need a lot lines of code to fix the bugs caused by the immature method executeScriptTags.
the pjax response content:
the test.js:
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.
The text was updated successfully, but these errors were encountered: