![]() |
#1 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 320
Karma: 3200000
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
|
Order of linked Javascripts
As a part of my workflow, I import and link two Javascript files early in a given project. I need em in a certain order, but I haven't yet been able to figure out how to get them to come in that way. It doesn't seem to insert them into the <head> alphabetically, and the order I click em in the import dialogue doesn't seem to affect it either.
It's just two files, so I usually just reorder them manually before splitting files per-chapter. But I was curious if there might be something I can do to get them to come in in the desired order in the first place. Is there? Last edited by phillipgessert; Yesterday at 02:09 PM. |
![]() |
![]() |
![]() |
#2 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,047
Karma: 6361556
Join Date: Nov 2009
Device: many
|
I think those links are placed immediately before the head end tag. So inserting them in order should work.
I will take a look at the code and get back to you. |
![]() |
![]() |
![]() |
#3 |
Fool
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 492
Karma: 4660650
Join Date: Feb 2003
Device: Kindle: Voyage,PW1,KOA, Kobo: Clara Colour, Nook GLP, Pocketbook verse
|
JavaScript links load asynchronously, so the second one may complete its fetch before the first one does even though the first link makes its fetch request earlier.. The fetched content (the "src" attributed) will be loaded into the open document in the order received from the relevant server(s).
|
![]() |
![]() |
![]() |
#4 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,047
Karma: 6361556
Join Date: Nov 2009
Device: many
|
I think he was talking about the order the link statements are inserted into the head tag or each xhtml file. I think, without any "async" or "defer" their order in head determines their order of execution once the body has been fully loaded.
Okay, I just got to my desktop and fired it up and created an epub with 4 xhtnml files and two javascript files named "Script0001.js" and Script0002.js". I then selected the 4 html files in BookBrowser and right clicked and included them. They were inserted in that order in every xhtml file. Are you seeing something different? If I wanted the order to be reversed, I simply select the xhtml files I want to add the links too, and then right clicked and selected Link Javascripts... and when the javascript selection window opened I used the up down caret keys on the right side of dialog to swap the order of the javascript files making Script0002.js come first (and made sure they were all checked). See the attached image. Sigil then used that order of linking. So I can not recreate what you are seeing about linkage order? Last edited by KevinH; Yesterday at 03:46 PM. |
![]() |
![]() |
![]() |
#5 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 320
Karma: 3200000
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
|
Quote:
Sorry for raising the issue when I don't have an example in hand, it's something I've worked with off an on for a few months and, Murphy's Law, naturally right now it's working precisely like it's supposed to. |
|
![]() |
![]() |
![]() |
#6 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,047
Karma: 6361556
Join Date: Nov 2009
Device: many
|
Figures! If you can ever figure out how to reproduce it, please do let me know. There could be a dictionary or map that does not keep order someplace in the execution but I could not see one.
This code was copied almost 100% from the link css files code as stylesheet order is important as the last sheet wins in case both are present. So it should be order consistent and preserving for the order generated by the dialog that selects the javascripts. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Order multi-series storyline in reading order | plaid | Kobo Reader | 2 | 02-23-2023 04:30 PM |
Default to allow javascripts to open windows | KevinH | Sigil | 5 | 08-01-2021 07:14 AM |
Linked Resource Does Not Exist | dbird | Editor | 18 | 10-10-2017 02:22 PM |
Collections created in cloud don't order themselves by alphabetical order | septentrion | Amazon Kindle | 4 | 12-25-2016 12:21 AM |
PRS-950 Order a 950 delivered now (not pre-order) for $239.99 | sun surfer | Sony Reader | 2 | 12-16-2010 11:06 AM |