lochmueller / sourceopt
Optimization of the final page: reformatting the (x)HTML output & removal of new-lines, comments and generator-info including search and replace strings using your regular expressions. In addition combines all SVG selected within content-elements into one <symbol> file and replaces <img> by <use>.
Fund package maintenance!
lochmueller
paypal.me/lochmueller
Installs: 415 556
Dependents: 3
Suggesters: 0
Security: 0
Stars: 22
Watchers: 6
Forks: 21
Open Issues: 0
Type:typo3-cms-extension
Requires
- php: ^8.1
- typo3/cms-core: ^12.4||^13.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.3
- phpmd/phpmd: ^2.10
- typo3/testing-framework: ^8.2
Replaces
- maxserv/replacecontent: *
- typo3-ter/replacecontent: *
- typo3-ter/sourceopt: 5.2.5
README
- SourceOpt : reformatting the (x)HTML output & removal of new-lines, comments and generator-info
- RegExRep : search and replace strings using your regular expressions ; embrace regex and migrate now
- SVGstore : combines all SVG selected within elements into one <symbol> file and replaces <img> by <use>
Version
>= 5.2.5
Lines 8 to 9 in 173f7bd
"php": "^8.1", | |
"typo3/cms-core": "^12.4||^13.4" |
<= 5.2.0 (legacy)
Lines 8 to 9 in 6663a8a
"php": "^7.4||^8.0", | |
"typo3/cms-core": "^9.5||^10.4||^11.5||^12.4" |
Installation
composer require lochmueller/sourceopt
-
via TypoScript
[constants]
@import 'EXT:sourceopt/Configuration/TypoScript/constants'
[setup]
@import 'EXT:sourceopt/Configuration/TypoScript/setup'
-
via input device
- add
[EXT:sourceopt/Configuration/TypoScript]
intoInclude static
atIncludes
inTemplate
- add
Configuration
Include the extension and go to the Constant Editor
of a template where you find all options under PLUGIN
Performance
The PHP process need server performance, because there are several search/replace operations in the logic
Reference
Note: The following features are executed in reverse order
SourceOpt
TypoScript [constants]
|| prepend config.
at [setup]
RegEx Replace
TypoScript [setup]
incl. stdWrap
config.replacer {
search {
1 = /(?<="|')\/?(fileadmin|typo3temp|uploads)/
give-me-cherries = /fruit/
wrapBoldly < tmp.find
wrapBoldly.wrap = /|/
}
replace {
1 = //cdn.tld/$1
give-me-cherries = cherry
wrapBoldly < tmp.repl
wrapBoldly.wrap = <b>|</b>
}
}
Note: both arrays will be ksort'ed in "natural order"
HowTo migrate
from jweiland/replacer : 1.4 - 2.x
1.4 - 2.x
- regex replace
config\.tx_(?:\w*replace\w*)
toconfig.replacer
- remove
config.tx_replacer.enable_regex = 1
from maxserv/replacecontent 2013 - 2017
- regex replace
config\.tx_(?:\w*replace\w*)
toconfig.replacer
from typo3-ter/ja_replacer 2009 - 2013 || phorax/ja-replacer 2016
composer install jweiland/replacer
& replace config.tx_ja_replacer
to config.tx_replacer
from typo3-ter/n84_contentreplacer 2016
- regex replace
config\.tx_(?:\w*replace\w*)
toconfig.replacer
from typo3-ter/fereplace 2011
composer install jweiland/replacer
& replace plugin.fereplace.pairs
to config.tx_replacer
.. ah .. and one regex
- search
(\n\s*)(\d+)(?:{\s+|\.)old\s*=\s*([^\n]+).+?new\s*=\s*([^\n]+)
- replace
$1search.$2 = $3\n$1replace.$2 = $4
from typo3-ter/regex 2009
- regex replace
config\.regex
toconfig.replacer
- regex replace
(?:\s)(\w+)\s*=\s*
tosearch.$1 =
- regex replace
(\w+)\.replacement\s*=\s*
toreplace.$1 =
SVGstore
TypoScript [constants]
|| prepend config.
at [setup]
ToDo:
- Try external packages like https://github.com/ArjanSchouten/HtmlMinifier