Initial commit

This commit is contained in:
2018-04-02 08:07:38 +02:00
commit 7330c1ed3e
2054 changed files with 405203 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
Caching
-------
The extension adds a folder inside the typo3temp directory that contains several subfolders for the different
processes. If you are interested in the naming conventions of the files, you are encouraged to read the
source code. Each file inside this folder contains a hash which is created with the md5 algorithm
with the original file contents as a source. This is extremely useful, because we can detect changes to script
files or stylesheets by a simple comparison and automatically include the current version in the next rendering process.
The scriptmerger registers itself to a hook which is called after clearing of the caches. The registered class
simply removes any files inside the mentioned directories above which have an access date that is older than
two weeks.

View File

@@ -0,0 +1,302 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../../Includes.txt
Constants
=========
Properties
^^^^^^^^^^
===================================================== ========================================== ======================= =============================================
Property Data type :ref:`t3tsref:stdwrap` Default
===================================================== ========================================== ======================= =============================================
externalFileCacheLifetime_ :ref:`t3tsref:data-type-integer` no 3600
css.enable_ :ref:`t3tsref:data-type-boolean` no 1
css.addContentInDocument_ :ref:`t3tsref:data-type-boolean` no 0
css.doNotRemoveInDoc_ :ref:`t3tsref:data-type-boolean` no 0
css.mergedFilePosition_ :ref:`t3tsref:data-type-string` no *empty*
css.minify.enable_ :ref:`t3tsref:data-type-boolean` no 1
css.minify.ignore_ :ref:`t3tsref:data-type-string` no \.min\.
css.compress.enable_ :ref:`t3tsref:data-type-boolean` no 1
css.compress.ignore_ :ref:`t3tsref:data-type-string` no \.gz\.
css.merge.enable_ :ref:`t3tsref:data-type-boolean` no 1
css.merge.ignore_ :ref:`t3tsref:data-type-string` no *empty*
css.uniqueCharset.enable_ :ref:`t3tsref:data-type-boolean` no 1
css.uniqueCharset.value_ :ref:`t3tsref:data-type-string` no @charset "UTF-8";
css.postUrlProcessing.pattern_ :ref:`t3tsref:data-type-string` no *empty*
css.postUrlProcessing.replacement_ :ref:`t3tsref:data-type-string` no *empty*
javascript.enable_ :ref:`t3tsref:data-type-boolean` no 1
javascript.addContentInDocument_ :ref:`t3tsref:data-type-boolean` no 0
javascript.parseBody_ :ref:`t3tsref:data-type-boolean` no 0
javascript.doNotRemoveInDocInBody_ :ref:`t3tsref:data-type-boolean` no 1
javascript.doNotRemoveInDocInHead_ :ref:`t3tsref:data-type-boolean` no 0
javascript.mergedHeadFilePosition_ :ref:`t3tsref:data-type-string` no *empty*
javascript.mergedBodyFilePosition_ :ref:`t3tsref:data-type-string` no </body>
javascript.deferLoading_ :ref:`t3tsref:data-type-boolean` no 0
javascript.minify.enable_ :ref:`t3tsref:data-type-boolean` no 1
javascript.minify.ignore_ :ref:`t3tsref:data-type-string` no \?,\.min\.
javascript.minify.useJSMinPlus_ :ref:`t3tsref:data-type-boolean` no 1
javascript.minify.useJShrink_ :ref:`t3tsref:data-type-boolean` no 0
javascript.compress.enable_ :ref:`t3tsref:data-type-boolean` no 1
javascript.compress.ignore_ :ref:`t3tsref:data-type-string` no \?,\.gz\.
javascript.merge.enable_ :ref:`t3tsref:data-type-boolean` no 1
javascript.merge.ignore_ :ref:`t3tsref:data-type-string` no \?
===================================================== ========================================== ======================= =============================================
Property Details
^^^^^^^^^^^^^^^^
externalFileCacheLifetime
"""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.externalFileCacheLifetime =` :ref:`t3tsref:data-type-integer`
“Time to live” in seconds for the cache files of external CSS and JS
css.enable
""""""""""
:typoscript:`plugin.tx_scriptmerger.css.enable =` :ref:`t3tsref:data-type-boolean`
Enable all css processes
css.addContentInDocument
""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.addContentInDocument =` :ref:`t3tsref:data-type-boolean`
Embed the resulting css directly into the document in favor of a
linked resource (this automatically disables the compression step).
css.doNotRemoveInDoc
""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.doNotRemoveInDoc=` :ref:`t3tsref:data-type-boolean`
This option can be used to prevent embedded scripts to be merged, minified or compressed.
css.mergedFilePosition
""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.mergedFilePosition=` :ref:`t3tsref:data-type-string`
Use this option to define the final position of the merged files and any other ones that were processed by
the scriptmerger. The value is used inside a regular expression, but you cannot use any wildcards or such stuff.
A possible value could be "</head>". If empty, the position of the first merged file is reused.
css.minify.enable
"""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.minify.enable =` :ref:`t3tsref:data-type-boolean`
Enable the minification process
css.minify.ignore
"""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.minify.ignore =` :ref:`t3tsref:data-type-string`
A comma-separated list of files which should be ignored from the minification process.
Be careful, because you need to quote the characters yourself as the entries are considered as regular expressions.
If a file is added to all three ignore options, it's not touched at all.
css.compress.enable
"""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.compress.enable =` :ref:`t3tsref:data-type-boolean`
Enable the compression process
css.compress.ignore
"""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.compress.ignore =` :ref:`t3tsref:data-type-string`
A comma-separated list of files which should be ignored from the compression process.
Be careful, because you need to quote the characters yourself as the entries are considered as regular expressions.
If a file is added to all three ignore options, it's not touched at all.
css.merge.enable
""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.merge.enable =` :ref:`t3tsref:data-type-boolean`
Enable the merging process
css.merge.ignore
""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.merge.ignore =` :ref:`t3tsref:data-type-string`
A comma-separated list of files which should be ignored from the merging process.
Be careful, because you need to quote the characters yourself as the entries are considered as regular expressions.
If a file is added to all three ignore options, it's not touched at all. Also this setting will trigger the
process to readd the file at the same position it was taken from.
css.uniqueCharset.enable
""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.uniqueCharset.enable =` :ref:`t3tsref:data-type-boolean`
Enables the replacement of multiple @charset definitions by the given value option
css.uniqueCharset.value
"""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.uniqueCharset.value =` :ref:`t3tsref:data-type-string`
@charset definition that is added on the top of the merged css files
css.postUrlProcessing.pattern
"""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.postUrlProcessing.pattern =` :ref:`t3tsref:data-type-string`
Regular expression pattern (e.g. /(fileadmin)/i)
The pattern and replacement values can be used to fix broken urls inside the combined css file.
css.postUrlProcessing.replacement
"""""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.css.postUrlProcessing.replacement =` :ref:`t3tsref:data-type-string`
Regular expression replacement (e.g. prefix/$i)
javascript.minify.enable
""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.minify.enable =` :ref:`t3tsref:data-type-boolean`
Enable the minification process
javascript.minify.ignore
""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.minify.ignore =` :ref:`t3tsref:data-type-string`
A comma-separated list of files which should be ignored from the minification process.
Be careful, because you need to quote the characters yourself as the entries are considered as regular expressions.
If a file is added to all three ignore options, it's not touched at all.
javascript.minify.useJSMinPlus
""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.minify.useJSMinPlus =` :ref:`t3tsref:data-type-boolean`
Use JSMin+ instead of JSMin or JShrink.
javascript.minify.useJShrink
""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.minify.useJShrink =` :ref:`t3tsref:data-type-boolean`
Use JShrink instead of JSMin or JSMin+.
javascript.compress.enable
""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.compress.enable =` :ref:`t3tsref:data-type-boolean`
Enable the compression process.
javascript.compress.ignore
""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.compress.ignore =` :ref:`t3tsref:data-type-string`
A comma-separated list of files which should be ignored from the compression process.
Be careful, because you need to quote the characters yourself as the entries are considered as regular expressions.
If a file is added to all three ignore options, it's not touched at all.
javascript.merge.enable
"""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.merge.enable =` :ref:`t3tsref:data-type-boolean`
Enable the merging process
javascript.merge.ignore
"""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.merge.ignore =` :ref:`t3tsref:data-type-string`
A comma-separated list of files which should be ignored from the merging process.
Be careful, because you need to quote the characters yourself as the entries are considered as regular expressions.
If a file is added to all three ignore options, it's not touched at all. Also this setting will trigger the
process to readd the file at the same position it was taken from.
javascript.enable
"""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.enable=` :ref:`t3tsref:data-type-boolean`
Enable all javascript processes (by default only for the head section)
javascript.addContentInDocument
"""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.addContentInDocument=` :ref:`t3tsref:data-type-boolean`
Embed the resulting javascript code directly into the document in favor of a
linked resource (this automatically disables the compression step).
javascript.parseBody
""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.parseBody=` :ref:`t3tsref:data-type-boolean`
Enable this option to enable the minification, processing and merging processes for the body section.
The resulting files are always included directly before the closing body tag.
javascript.doNotRemoveInDocInBody
"""""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.doNotRemoveInDocInBody=` :ref:`t3tsref:data-type-boolean`
This option can be used to prevent embedded scripts inside the document of the body section to be merged, minified
or compressed as this is in many cases a possible error source in the final result. Therefore the option is
enabled by default.
javascript.doNotRemoveInDocInHead
"""""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.doNotRemoveInDocInHead=` :ref:`t3tsref:data-type-boolean`
This option can be used to prevent embedded scripts inside the document of the head section to be merged,
minified or compressed.
javascript.mergedHeadFilePosition
"""""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.mergedHeadFilePosition=` :ref:`t3tsref:data-type-string`
Use this option to define the final position of the merged files and any other ones in the head section that
were processed by the scriptmerger. The value is used inside a regular expression, but you cannot use any
wildcards or such stuff. A possible value could be "</head>". If empty, the position of the first merged file
is reused.
javascript.mergedBodyFilePosition
"""""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.mergedBodyFilePosition=` :ref:`t3tsref:data-type-string`
Use this option to define the final position of the merged files and any other ones in the body section that
were processed by the scriptmerger. The value is used inside a regular expression, but you cannot use any
wildcards or such stuff.
javascript.deferLoading
"""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.javascript.deferLoading=` :ref:`t3tsref:data-type-boolean`
If you want to load your javascript always after the page onload event, then you are encouraged to activate this option.
Additional Information
^^^^^^^^^^^^^^^^^^^^^^
You can ignore any script or stylesheet by adding the data-ignore attribute with the value 1 to their tag.

View File

@@ -0,0 +1,40 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../../Includes.txt
Example
=======
The following configuration was used on one a production site. On this site all javascript and css files were
merged, compressed and minified. Furthermore I excluded any mootools scripts from being minified as they are
already provided as minified source. Also the deployJava script was ignored in the merging procecess, because this
script was added inside the body and the merging would cause an invalid loading order afterwards. On page
type 101,the scriptmerger plugin was completely disabled, because the type contains a template which was used by a
pdf generator extension that had several problems with the minified and merged scripts.
You see that it possible to get an advanced configuration with just some small changes to the configuration!
.. code-block:: typoscript
plugin.tx_scriptmerger {
javascript {
parseBody = 1
minify {
ignore = \?,\.min\.,mootools-
}
merge {
ignore = \?,deployJava
}
}
}
[globalVar = GP:type = 101]
plugin.tx_scriptmerger {
css.enable = 0
javascript.enable = 0
}
[global]

View File

@@ -0,0 +1,18 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
Configuration
-------------
This chapter describes the TypoScript extension parameters.
.. toctree::
:maxdepth: 5
:titlesonly:
:glob:
Constants/Index
Setup/Index
Example/Index

View File

@@ -0,0 +1,53 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../../Includes.txt
Setup
=====
Properties
^^^^^^^^^^
===================================================== ========================================== ======================= =============================================
Property Data type :ref:`t3tsref:stdwrap` Default
===================================================== ========================================== ======================= =============================================
urlRegularExpressions.pattern1_ :ref:`t3tsref:data-type-string` no *empty*
urlRegularExpressions.pattern1.replacement_ :ref:`t3tsref:data-type-string` no *empty*
urlRegularExpressions.pattern1.useWholeContent_ :ref:`t3tsref:data-type-boolean` no 0
===================================================== ========================================== ======================= =============================================
Property Details
^^^^^^^^^^^^^^^^
urlRegularExpressions
"""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.urlRegularExpressions =` :ref:`t3tsref:data-type-array`
Custom regular expressions that process any links on the site. Can be used to change links to use a CDN or an
special cookie-free asset domain. It's possible to define multiple expressions.
urlRegularExpressions.pattern1
""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.urlRegularExpressions.pattern1 =` :ref:`t3tsref:data-type-string`
Regular expression (e.g. http://domain.tld((filadmin\|typo3temp/).+))
urlRegularExpressions.pattern1.replacement
""""""""""""""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.urlRegularExpressions.pattern1.replacement =` :ref:`t3tsref:data-type-string`
Replacement expression (e.g. http://assets.domain.tld/$1)
urlRegularExpressions.pattern1.useWholeContent
""""""""""""""""""""""""""""""""""""""""""""""
:typoscript:`plugin.tx_scriptmerger.urlRegularExpressions.pattern1.useWholeContent =` :ref:`t3tsref:data-type-boolean`
Use the whole page content as the source for the regular expression instead of only URLs. In this case you must
handle the quoting and modifier stuff yourself (e.g. /http:\/\/de\./is)

View File

@@ -0,0 +1,21 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. This is 'Includes.txt'. It is included at the very top of each and
every ReST source file in this documentation project (= manual).
.. ==================================================
.. DEFINE SOME TEXT ROLES
.. --------------------------------------------------
.. role:: typoscript(code)
.. role:: ts(typoscript)
:class: typoscript
.. role:: php(code)
.. highlight:: guess

View File

@@ -0,0 +1,61 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. _start:
================
EXT:scriptmerger
================
.. only:: html
:Classification:
scriptmerger
:Author:
Stefan Galinski
:Version:
|release|
:Language:
en
:Description:
This extension minimizes the http requests by concatenating your css and javascript.
Furthermore the result can be minified and compressed. This whole process is highly configurable
and is partly based on the "minify", "jsminplus", "jshrink" and "jsmin" projects.
:Keywords:
performance, compression, merging, javascript, stylesheets
:Author:
Stefan Galinski
:Email:
stefan@sgalinski.de
:License:
This document is published under the Open Content License
available from http://www.opencontent.org/opl.shtml
:Rendered:
|today|
The content of this document is related to TYPO3,
a GNU/GPL CMS/Framework available from `www.typo3.org <http://www.typo3.org/>`_.
**Table of Contents**
.. toctree::
:maxdepth: 2
:titlesonly:
:glob:
Introduction/Index
Installation/Index
Configuration/Index
Caching/Index
KnownProblemsAndHints/Index

View File

@@ -0,0 +1,15 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
Installation
------------
The installation process of the extension isn't that simple, but don't give up too fast. First you need
to download and install the extension with the extension manager and include the static extension template
into your root page like you possibly did many times before for other extensions. As an additional step it's
required to include the contents of the example .htaccess file in the extension directory in your own site-wide
.htaccess - in most cases directly after the RewriteBase setting. Now you can finally test the output of your page
and tweak the scriptmerger configuration as it's possible that you will experience javascript errors or other
issues, because of a wrong order of the executed files.

View File

@@ -0,0 +1,22 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
Introduction
------------
This extension provides a significant speedup of your pages. The
speedup depends on the amount of css and javascript files that you
are using on your site. The performance advantage is gained by
concatenating, minimizing and compressing of all css and javascript
files. Furthermore the extension supports different media types and
relations (rel attribute) for css scripts and different output formats
of the result files. Currently you can write them back into the
document as links to external files, as embedded content or deferred scripts (js only).
The minification process and @import rule replacement logic is based
upon the extension „Minify“ that you can find at `Google Code <http://code.google.com/p/minify/>`_.
Furthermore `JSMinPlus <http://crisp.tweakblogs.net/blog/1665/a-new-javascript-minifier-jsmin+.html>`_
and `JShrink <https://github.com/tedivm/JShrink>`_ are used as better alternatives for JSMin in the javascript
minification process. You can still switch to JSMin if you experience trouble.

View File

@@ -0,0 +1,46 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
Known Problems And Hints
------------------------
- It's known that the used @import replacement utility from the „Minify“
project doesn't resolves URL's. It's not a real problem, because such
@import rules will simply not be replaced.
- The defer, async and rev attributes are completely ignored.
- Embedded css and javascript in the document is automatically added to an external, cachable file. If you want
to prevent this behaviour, just ignore the tags with the "data-ignore" attribute set to "1".
- If you experience problems with the compression, make sure you have
mod\_headers installed and activated. You can do this in e.g. ubuntu
with a simple „sudo a2enmod headers && sudo service apache2 restart“ command.
- You must have mod\_expires installed to use the expire dates feature in the .htaccess for the
images, css and javascript files. You can activate the module in e.g. ubuntu by this command:
„sudo a2enmod expires && sudo service apache2 restart“
- If you have some missing images after the merging process, you can use the "postUrlProcessing" option
to manually fix them. See the configuration chapter for additional information.
- Often problems are caused by an incorrect ordering after the concatenation process if
some files are ignored. You can fix that by defining a better position for your merged files. See the
configuration chapter for more information.
- You can disable the scriptmerger for the request by an URL parameter. Just add the following to your query string:
“?no\_cache=1&disableScriptmerger=1”.
- If you want to post-process the written files, because you want to push them to a CDN or something like that, you
can use the proviced internal hook. Just register some class in your ext_localconf.php into this array
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['scriptmerger']['writeFilePostHook'] and add the method "writeFilePostHook"
inside this class with the required logic.
- You can ignore any scripts and stylesheets by adding the data-ignore attribute with the value 1. This tags are
not touched in any way by the scriptmerger.
Your problem isn't listed here and you still experience issues with your minified, compressed and/or concatenated
contents? Then please report this at the project tracker
on `forge <http://forge.typo3.org/projects/extension-scriptmerger/issues>`_.