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

Load Order For JS Can Be Incorrect with Debugger on #158

Closed
bobrocke opened this issue Mar 19, 2015 · 5 comments
Closed

Load Order For JS Can Be Incorrect with Debugger on #158

bobrocke opened this issue Mar 19, 2015 · 5 comments
Labels

Comments

@bobrocke
Copy link

This code:

{% do assets.add('jquery', 110) %}
{% do assets.add('theme://js/captionate.js', 100) %}
{% do assets.add('theme://js/doubletaptogo.js', 90) %}`

loads the JS in the order expected: jquery, captionate and then doubletaptogo.

This code:

{% do assets.add('jquery', 110) %}
{% do assets.add('theme://js/captionate.js', 108) %}
{% do assets.add('theme://js/doubletaptogo.js', 106) %}

loads the JS in an unexpected order: captionate, doubletaptogo, and then jquery.

@rhukster rhukster added the bug label Mar 19, 2015
@rhukster
Copy link
Member

Well it's weird. I've tried breaking the ordering and even used your exact example, but it always seems to order as expected for me. The only thing you are changing is the order?

@bobrocke
Copy link
Author

Yes, just switching the numbers switches the load order. It appears the 108 and 106 don't behave like even multiples of 10. I'll try some other numbers and see what I get.

@bobrocke
Copy link
Author

This one:

{% do assets.add('jquery', 1110) %}
{% do assets.add('theme://js/captionate.js', 200) %}
{% do assets.add('theme://js/doubletaptogo.js', 100) %}

gives me captionate, jquery and then doubletaptogo!

@rhukster
Copy link
Member

Ah! This is only when the debugger is on. I know what this is. Basically the debugger is adding jquery with a "101" order. As this added first, and duplicates are skipped, that explains why you are seeing this ordering weirdness when debugger is activated, and I was not seeing it when debugger was off.

There's really only three options:

  1. document the debugger process so this is a known behavior
  2. move the priority to something very high (100001) as jquery should always be first
  3. do not skip duplicates, simply replace them. The theme will be last and override any existing order.

I'm leaning towards #3 as the best option.

@rhukster rhukster changed the title Load Order For JS Can Be Incorrect Load Order For JS Can Be Incorrect with Debugger on Mar 20, 2015
@rhukster
Copy link
Member

Fixed with commit commit f3d099e using approach 3

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

No branches or pull requests

2 participants