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.
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.
-
Have you tried including the script just after where your
<span>
s are in your HTML, or anywhere before your other scripts? – Bojangles Commented Jun 8, 2012 at 10:51
2 Answers
Reset to default 6Order of precedence is determined by the order in which things load.
- Head tag scripts (in the order they are listed)
- Scripts & other event attributes in the order they appear in the code.
- Body onLoad
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.
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.