Hi Steve,
I just took a look at your code and want to give you my feedback:
1. you are executing the code using "onload" event, which is fired
when complete website is downloaded including images etc. , "domready"
should work for your script too and execute much earlier.
2. I suppose you have already heared about closures in js which enable
you to have a bit privacy? :) The most functions in your code could be
defined as private and enable minifiers to rewrite them and make the
code smaller :)
3. CJS.eval - this will work for IE correctly, but window.eval gives
access to the current scope for the evaled code. This is ok if you
write your whole code in global scope, but if not - it could have side
effects, so take a look at "globalEval" method of jQuery.
4. document.write override is not possible to do for all usecases.
Example:
document.write("<script src="this/script/makes/even/more/
document.write/with/external/scripts"></script>")
Actually you have to download the code, look if there some more
document.write, look if there a script tags with external ressources,
download them and look for scripts again, and then have fun executing
all this without to brake it :)
This stuff is awful but it really exists in widgets code.
5. There is also "document.writeln" :)
6. If there are a lot of scripts and you are loading them async - it
is possible that you reach max connections browser limit and instead
to enable non-blockin loading of the page - you will block it because
images on the page will have to wait for scripts.
7. You didn't write any unit tests :) - how do you want to ensure your
code works in all browsers now and after some changes ....
regards,
Oleg
@oleg008
github.com/kof