[thelist] preparing Javascript code for release in xhtml templates

Scott Blanchard sblanchard at octane8.com
Thu Jan 13 06:46:33 CST 2005


I'm currently in a debate with a colleague over the merits of stripping
inline javascript code of it's formatting (one-lining, if you will) just
prior to releasing it to the client. Obviously, externalizing it via the src
attr is the best approach, but sometimes were creating this javascript on
the fly via ASP or .NET so that's not always an option.

For example, if I have an otherwise xhtml/css compliant template that
contains the following function in the HEAD section...

Function foo(){
	Var bar;
	Alert("do you really need to see the code this way once it's
released?")
}


Becomes "one-lined" and "de-spaced" to ...

Function foo(){Var bar;Alert("do you really need to see the code this way
once it's released? Yes this is much better if we cannot externalize the
script")}


Losing all it's dev friendly formatting but minimizing the character count
for SEO strategy as well as minor obsfucation of the business logic.

The developer has countered that he will not be able to support this code
because it will cost him time to convert the code back to human readable
format in the event that post release bugs are reported. He suggests putting
the code at the bottom of the page so that it does not hinder SEO. I
completely disagree with this.

What are your thoughts?



More information about the thelist mailing list