Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with scripts execution order #259

Closed
diogomafra opened this issue Mar 1, 2013 · 4 comments
Closed

Problem with scripts execution order #259

diogomafra opened this issue Mar 1, 2013 · 4 comments

Comments

@diogomafra
Copy link

Hi, I have a problem related to the script execution order. It was working in the version 1.4.0, but it's not in the 1.5.0.

In the version 1.4.0, all scripts defined inside the pjax container were executed synchronously, but now, it executes first the inline script and later the loaded scripts(with 'src'). You can see a test here: diogomafra@43206a4

I think it should execute the scripts in order they are defined, right?

@josh
Copy link
Contributor

josh commented Mar 1, 2013

It's an intentional change.

On Mar 1, 2013, at 7:55 AM, Diogo Edegar Mafra notifications@github.com wrote:

Hi, I have a problem related to the script execution order. It was working in the version 1.4.0, but it's not in the 1.5.0.

In the version 1.4.0, all scripts defined inside the pjax container were executed synchronously, but now, it executes first the inline script and later the loaded scripts(with 'src'). You can see a test here: diogomafra/jquery-pjax@43206a4

I think it should execute the scripts in order they are defined, right?


Reply to this email directly or view it on GitHub.

@diogomafra
Copy link
Author

I was expecting the execution order to be:

  1. pjax request
  2. scripts evaluated
  3. pjax success

Maybe I'm doing something wrong, but how do you solve something like this:

I'm setting up the page on the 'pjax:success' event (as we would do using the document.ready), and it depends on a script that is loaded only on that page. But, right now, the pjax:success event is raised before the javascript is loaded.

Probably I have to load the code that is executed on 'pjax:success' after the library is loaded. Something like this:

<div class='my_pjax_response'>
<script src="my_library.js">
<script src="my_library_execution.js">
</div>

@josh
Copy link
Contributor

josh commented Mar 1, 2013

There's no way to have blocking scripts without resorting to eval.

On Mar 1, 2013, at 8:16 AM, Diogo Edegar Mafra notifications@github.com wrote:

I was expecting the execution order to be:

  1. pjax request
  2. scripts evaluated
  3. pjax success

Maybe I'm doing something wrong, but how do you solve something like this:

I'm setting up the page on the 'pjax:success' event (as we would do using the document.ready), and it depends on a script that is loaded only on that page. But, right now, the pjax:success event is raised before the javascript is loaded.

Probably I have to load the code that is executed on 'pjax:success' after the library is loaded. Something like this:

<script src="my_library_execution.js"> — Reply to this email directly or view it on GitHub.

@diogomafra
Copy link
Author

OK. I'm closing this issue.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants