Project

General

Profile

Actions

Bug #97324

closed

CSS / JS files not referenced correctly when concatenation and compression are disabled

Added by Marco Kuprat over 2 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2022-04-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

After updating a site from TYPO3 10.4 to 11.5.8 I encountered following problem:
The frontend of subpages from level 2 got messed up, because CSS and JS files were not referenced correctly (loading those files resulted in a 404 error).

Example TypoScript setup in order to reproduce the error:

config.minifyCSS = 0
config.concatenateCss = 0
config.compressCss = 0
config.minifyJs = 0
config.concatenateJs = 0
config.compressJs = 0

page.includeCSS.mycss = fileadmin/mycss.css
page.includeJS.myjs = fileadmin/myjs.js

In TYPO3 11.5 the CSS and JS files are referenced like this:
<link rel="stylesheet" type="text/css" href="fileadmin/mycss.css">
<script src="fileadmin/myjs.js?1570519026"></script>

Whereas in TYPO3 10.4 they were referenced with a prepending slash:
<link rel="stylesheet" type="text/css" href="/fileadmin/mycss.css">
<script src="/fileadmin/myjs.js?1570519026"></script>

So on subpages like https://www.domain.xy/page-1/subpage-1-1/ the references lead to a 404 error.

Setting config.absRefPrefix = / (or any other values) in TypoScript does not help.
However it works when config.baseURL is set, but that is deprecated.
Also, the problem does not exist as soon as config.concatenateCss = 1 or config.compressCSS = 1 are set (JS respectively), because in that case the references look like " /typo3temp/assets/compressed... "


Related issues 2 (2 open0 closed)

Related to TYPO3 Core - Bug #99135: page.includeCSS with resource from fileadmin, the beginning slash is missing TYPO3 11.5.19New2022-11-19

Actions
Related to TYPO3 Core - Bug #82574: Inconsistent support of config.absRefPrefix in fluid/extbaseNew2017-09-28

Actions
Actions #1

Updated by Marco Kuprat over 2 years ago

  • Project changed from 9 to TYPO3 Core
  • TYPO3 Version set to 11
  • PHP Version set to 7.4
Actions #2

Updated by Česlav Przywara over 2 years ago

A bit off topic: where did you get that config.baseURL is deprecated?

Looking at 11.5 docs, I don't see any deprecation being mentioned: https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Setup/Config/Index.html#baseurl

Actions #3

Updated by Marco Kuprat over 2 years ago

That's right, "deprecated" is the wrong wording.
But with the possibility of site management since TYPO3 9 there's normally no need for config.baseURL anymore.

My frontend was OK without config.baseURL when the site was running TYPO3 10.4. But after the upgrade to TYPO3 11.5 it crashed and I regard setting config.baseURL as workaround.
Of course, you could also add preceding slashes to page.includeCSS and page.includeJS in order to solve the problem.
But on the other hand I don't see a requirement for that in the docs.

So, all in all I regard this as a bug or at least missing documentation.

Actions #4

Updated by Riccardo De Contardi over 2 years ago

  • Category set to Frontend
Actions #5

Updated by Arne Bracht about 2 years ago

  • Related to Bug #99135: page.includeCSS with resource from fileadmin, the beginning slash is missing TYPO3 11.5.19 added
Actions #6

Updated by Knut E. over 1 year ago

A bit off topic: where did you get that config.baseURL is deprecated?

deprecated in TYPO3 Version 12.1

so the question for me what to do: the effect ist still in TYPO3 11.5.26: Add a Slash at the beginning of the files or is there another solution?

Actions #7

Updated by Knut E. over 1 year ago

a possible Solution via site:base from siteconfiguration

page = PAGE
page.headTag.append = TEXT
page.headTag.append.dataWrap = <base href="{site:base}">

Actions #8

Updated by Riccardo De Contardi over 1 year ago

Knut E. wrote in #note-6:

so the question for me what to do: the effect ist still in TYPO3 11.5.26: Add a Slash at the beginning of the files or is there another solution?

Is there a reason not to write directly:

page.includeJS.myjs = /fileadmin/myjs.js

?

Actions #9

Updated by Riccardo De Contardi over 1 year ago

  • Related to Bug #82574: Inconsistent support of config.absRefPrefix in fluid/extbase added
Actions #10

Updated by Knut E. over 1 year ago

Is there a reason not to write directly:

[...]

?

I think both solutions work. The leading slash you have to add to every file. If there are extensions or more files it can be a little bit faster with the other workaround. I don't know if a solution is preferable.

Actions #11

Updated by Garvin Hicking 4 months ago

  • Status changed from New to Closed

I'm closing this issue because with TYPO3v12 the asset locations changed to EXT:xxx notation, which resolve files differently. The old direct approach to including files then should utilize absolute paths from the document root to work properly, but it is recommended to use a sitepackage for containing assets and getting them referenced. Additionally, some other workarounds have been posted here which might work for others.

To foster this adoption, changing the "old" functionality is very unlikely at this point, so I hope you can understand for cleanup reasons that this issue got closed.

Actions

Also available in: Atom PDF