Bug #55264
Epic #55575: Streamline JavaScript Code in the TYPO3 Backend
requireJS for frontend in PageRenderer and TypoScript
Status: | Under Review | Start date: | 2014-01-23 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Daniel Siepmann | % Done: | 0% |
|
Category: | TypoScript | Spent time: | - | |
Target version: | 7.5 | |||
TYPO3 Version: | 6.2 | Is Regression: | No | |
PHP Version: | Sprint Focus: | |||
Complexity: |
Description
The class \TYPO3\CMS\Core\Page\PageRenderer, per definition "This class render the HTML of a webpage, usable for BE and FE" has two functions regarding requireJS.
loadRequireJs
loadRequireJsModule
Both are designed just for backend modules.
All paths are set relative from PATH_typo3.
Also it is not possible to include requireJS with TypoScript and add modules.
With distributions in mind, it should be possible to include requireJS with TypoScript, define main module/config and extend with packages(extensions) by PHP.
Related issues
History
#1 Updated by Daniel Siepmann over 1 year ago
- Parent task set to #55575
#2 Updated by Daniel Siepmann over 1 year ago
Should also be possible and used for sysext. One API for all.
Each extension should register her modules. (Already done in PageRenderer->loadRequireJs() for whole Resources/Public/JavaScript-Folder of each extension).
#3 Updated by Daniel Siepmann over 1 year ago
- Assigned To set to Daniel Siepmann
#4 Updated by Daniel Siepmann over 1 year ago
We have to document that the official supported file structure for extensions is
'EXT:' . $packageName . '/Resources/Public/JavaScript/'
With upper J and S!
#5 Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/28221
#6 Updated by Daniel Siepmann over 1 year ago
As documented in http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Page/Index.html you can add requireJS the same way:
An example setup can be:
javascriptLibs { requireJs = 1 requireJs { paths { jquery = {$page.includePath.javascript}Libs/jquery-1.10.2.min theme = {$page.includePath.javascript}Libs/bootstrap.min } data-main = {$page.includePath.javascript}main shim { theme.deps { 0 = jquery } } } }
Define your own location for jquery, add twitter bootstrap and define the main js file as entry point.
Wrap the content of your main as documented on http://requirejs.org
require(['jquery', 'theme'], function($) { // youre code });
No more need to include all of your libs and js files. Just add a "bootstrap" js file that decides which files to load. Each file uses the requirements through requirejs.
It's possible to pass everything to requreJs just by adding it to TypoScript.
Just "paths" and "data-main" will be parsed.
#7 Updated by Gerrit Code Review over 1 year ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/28221
#8 Updated by Thomas Hucke over 1 year ago
I'd like to have this also backported to 6.1.
#9 Updated by Alexander Opitz about 1 month ago
- Category set to TypoScript
- Target version set to 7.5
Set target version to 7.5 as it was mentioned in the review.
There is also http://review.typo3.org/36857 on the same aspect.