Reputation: 2786
Do you know if it is possible to make sure that a JavaScript script site is ran first in a web page?
For the context, I'm trying to tag every span
before another library (just like cufon) kicks in and messes with the original content. Since it's not possible to use onLoad()
on spans, it's the only way I can see to do that on the client side.
Upvotes: 5
Views: 4933
Reputation: 2651
Order of precedence is determined by the order in which things load.
I did have #2 & #3 mixed up - to clarify the body onLoad event fires after the entire body (scripts included) loads
Also, scripts altering <span>
tags will have no effect if placed in the head tag (unless they are a function) since the script runs when it is loaded, and when the head loads, the body & span tags haven't loaded yet.
Upvotes: 6
Reputation: 22471
Place <script>
tag in page source after content that you need to modify, but before any other scripts. Scripts run in same order that their tags appear on page.
Upvotes: 1