TYPO3: Cleanup your FE HTML source code
TYPO3 produces a lot of comments, prefixes, metatags etcetra… You might want to clean your HTML source code when your website is complete. In order to do this you need TypoScript!
Note 1: This is a 'living document' and will be updated when I
discover new or better methodes. Less = more :)
Last update: 3 November 2009.
Note 2: This might be a bit too much cleanup so please adjust
the code to your needs. I'm working on more documentation!
config {
# Disable the comment which comes with every content element
disablePrefixComment = 1
# Disable the border attribute in images
disableImgBorderAttr = 1
# Put inline css styles into a external css file
inlineStyle2TempFile = 1
# In the title tag, set the page title before the website title
pageTitleFirst = 1
# Remove the default JS file (copy into custom JS file!)
removeDefaultJS = 1
}
tt_content {
 stdWrap.prefixComment >
# Warning: By unsetting `tt_content.stdWrap.dataWrap`, you
# remove the ability for anchor links to work when selecting
# content elements on a page for a link.
stdWrap.dataWrap >
stdWrap.innerWrap.cObject >
stdWrap.innerWrap2 >
}
tt_content.image.20 {
imageStdWrap.dataWrap >
imageStdWrapNoWidth.wrap >
imageColumnStdWrap.dataWrap >
# Unsettting rendering.dl will clean up the DL tags but might
# break your CSS code when applied afterwards.
rendering.dl >
}
lib {
parseFunc_RTE.nonTypoTagStdWrap.encapsLines.addAttributes.P.class >
stdheader {
stdWrap {
dataWrap >
prefixComment >
}
10.stdWrap.wrap >
}
}
# Below: Use only if you have DC tags in your source
# This is often seen but not by default
plugin.meta.flags.DC = 0
page.headerData.999 < plugin.meta

Do you have a sample URL to share with the results of the above page cleaning?
A warning, by unsetting `tt_content.stdWrap.dataWrap`, you remove the ability for anchor links to work when selecting content elements on a page for a link.
A tip, by simply setting `tt_content.stdWrap.prefixComment >` you remove the need to specifically unset the individual content element types via `XXX.stdWrap.prefixComment >`.
In you’re using `plugin.meta`, are using the built-in deprecated `plugin.meta` template or extension metatags?
Cheers and thanks for the blogging.
Hai Michael,
Thanks for the heads-up, didn’t notice!
I had never seen the DC tags from the meta plugin until a week ago. Since the website wasn’t my own I didn’t remove the plugin (couldn’t figure out the purpose) but simply disabled the tags using the code above. I actually found the particular code through another website, but I can’t remember which one….
Maarten, You’re welcome for the suggestions.
I know metatags and deprecated plugin.meta have the DC options, but I haven’t seen documentation to where those are worthwhile on the web. Must be an academic thing.
Did you test setting “tt_content.image.20.layout.default.value” once without the `< tt_content.image.20.layout.default.value` resets? I think the reset of tt_content.image.20.layout.default.value will be picked up on the more specific components.
The document has been updated again…
- More documentation (still not enough)
- Smaller code with same results (30%!)
- Removed some unwanted results
Hi Maarten,
do you have a suggestion how you can ‘move’ the javascript for the GMENU and the mouse-over (CDATA) to an external file?
Tnx Feek
Hi Feek,
This issue has been around for a while and even though there is a patch available it’s not yet implemented into the TYPO3 Core. The feature is set for version 4.4 but you can also patch right now:
http://bugs.typo3.org/view.php?id=5064
Tnx,
that works for me :)