Porsche Design SystemSearchNavigate to GitHub repository of Porsche Design SystemOpen sidebar
Cookies Fallback Script Table of Contents Function name: getCookiesFallbackScript() Although the Porsche Design System does not rely on browser cookies, a blocking overlay is shown asking the user to activate browser cookies in case those are disabled completely. Therefore, we provide a ready to use partial in all @porsche-design-system/components-{js|angular|react|vue} packages which needs to be injected before the closing </body> of your index.html. Force display of cookies fallback Supported options OptionDescriptionTypeDefaultcdnDecides from which CDN the resources are loaded.'auto' | 'cn''auto'formatDefines the output format of the partial. By default, it returns a html string. For jsx it returns a jsx element. For sha256 it returns a SHA-256 hash of the innerHTML to use in a Content Security Policy (CSP).'html' | 'jsx' | 'sha256''html' When using jsx in the format option, it is necessary to have react/jsx-runtime as a dependency in the project included. Examples Project integration differs based on the project setup. The following showcases the most common ways.
<!-- index.html -->
<body>
  <!--PLACEHOLDER_COOKIES_FALLBACK_SCRIPT-->
</body>

<!-- package.json (tested on macOS, the script may need to be adjusted depending on the operating system used) -->
<!-- make sure to adjust the path to the index.html file -->
"scripts": {
  "prestart": "yarn replace",
  "replace": "placeholder='<!--PLACEHOLDER_COOKIES_FALLBACK_SCRIPT-->' && partial=$placeholder$(node -e 'console.log(require(\"@porsche-design-system/components-js/partials\").getCookiesFallbackScript())') && regex=$placeholder'.*' && sed -i '' -E -e \"s^$regex^$partial^\" index.html"
  <!-- Alternative: Force using China CDN -->
  "replace": "placeholder='<!--PLACEHOLDER_COOKIES_FALLBACK_SCRIPT-->' && partial=$placeholder$(node -e 'console.log(require(\"@porsche-design-system/components-js/partials\").getCookiesFallbackScript({ cdn: \"cn\" }))') && regex=$placeholder'.*' && sed -i '' -E -e \"s^$regex^$partial^\" index.html"
}
OutputThe result of this partial looks like this:
<script>
!function(){if(!(window.navigator||navigator).cookieEnabled){const o=document.createElement("script");o.src="https://cdn.ui.porsche.com/porsche-design-system/fallbacks/cookies.a9ad23a.js",document.body.appendChild(o)}}();
</script>

// Alternative: Force using China CDN
<script>
!function(){if(!(window.navigator||navigator).cookieEnabled){const o=document.createElement("script");o.src="https://cdn.ui.porsche.cn/porsche-design-system/fallbacks/cookies.a9ad23a.js",document.body.appendChild(o)}}();
</script>
Translations Automatic translations for the following languages are provided: 'de' | 'ru' | 'fr' | 'en' | 'it' | 'pt' | 'es' | 'ja' | 'ko' | 'zh' | 'nl' | 'pl' | 'cs' | 'da' | 'et' | 'fi' | 'lt' | 'lv' | 'no' | 'sl' | 'sv' | 'tr' | 'uk' As soon as the Cookies Fallback script initializes, it looks for the obligatory lang attribute defined in the html tag. Support is given for the following formats, e.g.: lang="en" lang="en_US" lang="en-US" If none of these languages can be found, it will fall back to en. Troubleshooting There always might be a case where something goes wrong. Here are some possible answers: Q: Why does the translation not get recognized automatically? A: Mostly this is a result of false order of script loading and setting translation key by the application. It's required that the lang attribute in the html tag is defined with the correct value before the Cookies Fallback script gets initialized. A: The translation key is not part of the provided keys (see "Translations") A: The translation key has not the correct format (see "Translations") Q: Why are there no implementation guidelines for my JS framework? A: Implementing a third party script can be done in many ways regarding the setup of your application. So there isn't a solely true way to integrate it in a specific framework. Just one rule of thumb: It should be initialized as late as possible.
Global settingsThemeChanges the theme of the application and any Porsche Design System component. It's possible to choose between forced theme light and dark. It's also possible to use auto, which applies light or dark theme depending on the operating system settings automatically.LightDarkAuto (sync with operating system)DirectionChanges the direction of HTML elements, mostly used on<html> tag to support languages which are read from right to left like e.g. Arabic.LTR (left-to-right)RTL (right-to-left)AutoText ZoomChanges the text size and values with unit rem or em relatively. This setting can be defined in browser settings for any website or by an application itself on<html> tag. To achieve WCAG 2.2 AA compliance it's obligatory to support text zoom up to at least 200%.100%130%150%200%